Hello everyone
 
I am not sure how to close a request to you again. 
 
Meanwhile I found the error in the code section myself. The names of the parameters are not e.g. 'AVG ' as specified in the QGIS module logfile, instead they are 'AVG             ' (note the long 13 space after the G) as specified in the QGIS history. 
 
Hence the correct code for this module would be as follows:
processing.run("saga:pointstatisticsforpolygons", {'POINTS':'C:/[...]Test_points.shp','POLYGONS':'C:/[...]/Test_Polygons.shp','FIELDS':'VALUE','FIELD_NAME':3,'SUM             ':True,'AVG             ':True,'VAR             ':True,'DEV             ':True,'MIN             ':True,'MAX             ':True,'NUM             ':True,'STATISTICS':'C:/[...]/Test_Output.shp'})
 
Best,
Anna
 
 
Gesendet: Dienstag, 08. November 2022 um 13:17 Uhr
Von: "QGIS4you2--- via Qgis-user" <[email protected]>
An: [email protected]
Betreff: [Qgis-user] Parameter Inputs (False/True) for SAGA: 'Point statistics for polygon' module is not passed correctly in QGIS python console
 
Hello everyone
 
I work mostly with QGIS 3.18 (SAGA 2.3.2), but the problem also exists in QGIS 3.22 (SAGA 7.8.2) and QGIS 3.28 (SAGA 7.8.2). 
 
If I run the SAGA module 'Point statistics for polygon' via the QGIS Processing Toolbox and check the calculation of Sum, Mean (= AVG), Variance (= VAR), Deviation (= DEV), Minimum, Maximum and Count (= NUM), these values are displayed in the output shp file.
 
If I do the same with the Python Console (same settings, same layer, same output layer) the inputs (True/False) for Sum, Mean, Variance, Deviation, Minimum, Maximum and Count are ignored and just the SAGA default setting (AVG = True, everything else = False) is executed for this module. Furthermore, the command is executed without error. 
 
My Python code:
Note: For clarity, I shortened below the file paths with [...].
 
>>>from qgis import processing
>>>processing.run('saga:pointstatisticsforpolygons', {'AVG ' : True, 'DEV ' : True, 'FIELDS' : 'VALUE', 'FIELD_NAME' : 3, 'MAX ' : True, 'MIN ' : True, 'NUM ' : True, 'POINTS' : 'C:/[...]Test_points.shp', 'POLYGONS' : 'C:/[...]/Test_Polygons.shp', 'STATISTICS' : 'C:/[...]/Test_Output.shp', 'SUM ' : True, 'VAR ' : True}) 
 
Does anyone have an idea what the reason for this behavior could be? And how can I solve this problem? (Other modules (non-SAGA) are executed correctly via the Python Console).
If not, is there a way to change the default setting in SAGA?
 
Thanks for your help.
Anna
 
_______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to