-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a workaround for the qgis type 'aggregates'? #56
Comments
My guess is that it probably won't work until we use JSON to specify the algorithm. The aggregates argument is its own argument type ("aggregates") which I'm guessing means that it is a Python object. If you can figure out the proper JSON specification for the aggregates type it will help me implement it when I get there! (Probably in about two months). A workaround might be to make a Workflow (model? pipeline? I forget the QGIS terminology) which you can run using |
It might be possible. The Each record looks like this and specifies one output column:
|
That matches the GUI: I guess since shell experiments$ qgis_process help native:aggregate # not all output shown
----------------
Arguments
----------------
INPUT: Input layer
Argument type: source
Acceptable values:
- Path to a vector layer
GROUP_BY: Group by expression (NULL to group all features)
Argument type: expression
Acceptable values:
- A valid QGIS expression string, e.g "road_name" = 'MAIN RD'
AGGREGATES: Aggregates
Argument type: aggregates
OUTPUT: Aggregated
Argument type: sink
Acceptable values:
- Path for new vector layer $ qgis_process run native:aggregate -- INPUT=sg_repairedgeom.gpkg AGGREGATES={} OUTPUT=try.gpkg
qt5ct: using qt5ct plugin
- 'VirtualXPath' [XML Path Language - XPath]
- 'VirtualXPath' [XML Path Language - XPath]
Problem with SAGA installation: SAGA was not found or is not correctly installed
----------------
Inputs
----------------
AGGREGATES: {}
INPUT: sg_repairedgeom.gpkg
OUTPUT: try.gpkg
- 'VirtualXPath' [XML Path Language - XPath]
ERROR: An error was encountered while checking parameter values
Incorrect parameter value for AGGREGATES $ qgis_process run native:aggregate -- INPUT=sg_repairedgeom.gpkg AGGREGATES={'aggregate':'sum','delimiter':',','input':'\"fid\"','length':0,'name':'fid','precision':0,'type':4} OUTPUT=try.gpkg
qt5ct: using qt5ct plugin
- 'VirtualXPath' [XML Path Language - XPath]
- 'VirtualXPath' [XML Path Language - XPath]
Problem with SAGA installation: SAGA was not found or is not correctly installed
----------------
Inputs
----------------
AGGREGATES:
INPUT: sg_repairedgeom.gpkg
OUTPUT: try.gpkg
- 'VirtualXPath' [XML Path Language - XPath]
ERROR: An error was encountered while checking parameter values
Incorrect parameter value for AGGREGATES $ qgis_process run native:aggregate -- INPUT=sg_repairedgeom.gpkg AGGREGATES={aggregate:sum,delimiter:',',input:fid,length:0,name:fid,precision:0,type:4} OUTPUT=try.gpkg
qt5ct: using qt5ct plugin
- 'VirtualXPath' [XML Path Language - XPath]
- 'VirtualXPath' [XML Path Language - XPath]
Problem with SAGA installation: SAGA was not found or is not correctly installed
----------------
Inputs
----------------
AGGREGATES:
INPUT: sg_repairedgeom.gpkg
OUTPUT: try.gpkg
- 'VirtualXPath' [XML Path Language - XPath]
ERROR: An error was encountered while checking parameter values
Incorrect parameter value for AGGREGATES $ qgis_process run native:aggregate -- INPUT=sg_repairedgeom.gpkg AGGREGATES="{'aggregate': 'sum','delimiter': ',','input': '\"fid\"','length': 0,'name': 'fid','precision': 0,'type': 4}" OUTPUT=try.gpkg
qt5ct: using qt5ct plugin
- 'VirtualXPath' [XML Path Language - XPath]
- 'VirtualXPath' [XML Path Language - XPath]
Problem with SAGA installation: SAGA was not found or is not correctly installed
----------------
Inputs
----------------
AGGREGATES: {'aggregate': 'sum','delimiter': ',','input': '"fid"','length': 0,'name': 'fid','precision': 0,'type': 4}
INPUT: sg_repairedgeom.gpkg
OUTPUT: try.gpkg
- 'VirtualXPath' [XML Path Language - XPath]
ERROR: An error was encountered while checking parameter values
Incorrect parameter value for AGGREGATES |
@paleolimbot "the JSON interface for the command-line runner" (from #40 (comment)): is it described somewhere? Didn't see that in https://docs.qgis.org/3.16/en/docs/user_manual/processing/standalone.html. The
|
You're right...this applies only to output. I was remembering qgis/QGIS#39324 (comment) but it looks like that was never implemented (unless I'm missing something from my reading of the source code). @nyalldawson Did I interpret that correctly (that you can't use JSON via stdin)? JSON via stdin would also help with passing WKT2 as a command-line argument in Windows because of some complexities with shell parsing when running .bat files as an external process. |
@paleolimbot thanks for the reference. Also, it appears that, from |
specified as a JSON object passed via stdin to qgis_process This provides a mechanism to support complex input parameters for algorithms, and a way for qgis_process to gain support for parameter types which are themselves specified as a dictionary type object. To indicate that parameters will be specified via stdin then the qgis_process command must follow the format qgis_process run algid - (with a trailing - in place of the usual arguments list). The JSON object must contain an "inputs" key, which is a map of the input parameter values. E.g. echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer - Specifying input parameters via stdin implies automatically the --json output format for results. One big motivation behind this enhancement is to provide a way for the qgisprocess R libraries to support parameter types such as aggregates. Refs r-spatial/qgisprocess#56 Refs r-spatial/qgisprocess#44 Sponsored by the Research Institute for Nature and Forest, Flemish Govt
@paleolimbot qgis/QGIS#46497 should provide a solution to this! Are you able to take a look and confirm that the enhancement work for you to help address this issue? |
specified as a JSON object passed via stdin to qgis_process This provides a mechanism to support complex input parameters for algorithms, and a way for qgis_process to gain support for parameter types which are themselves specified as a dictionary type object. To indicate that parameters will be specified via stdin then the qgis_process command must follow the format qgis_process run algid - (with a trailing - in place of the usual arguments list). The JSON object must contain an "inputs" key, which is a map of the input parameter values. E.g. echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer - Specifying input parameters via stdin implies automatically the --json output format for results. One big motivation behind this enhancement is to provide a way for the qgisprocess R libraries to support parameter types such as aggregates. Refs r-spatial/qgisprocess#56 Refs r-spatial/qgisprocess#44 Sponsored by the Research Institute for Nature and Forest, Flemish Govt
specified as a JSON object passed via stdin to qgis_process This provides a mechanism to support complex input parameters for algorithms, and a way for qgis_process to gain support for parameter types which are themselves specified as a dictionary type object. To indicate that parameters will be specified via stdin then the qgis_process command must follow the format qgis_process run algid - (with a trailing - in place of the usual arguments list). The JSON object must contain an "inputs" key, which is a map of the input parameter values. E.g. echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer - Specifying input parameters via stdin implies automatically the --json output format for results. One big motivation behind this enhancement is to provide a way for the qgisprocess R libraries to support parameter types such as aggregates. Refs r-spatial/qgisprocess#56 Refs r-spatial/qgisprocess#44 Sponsored by the Research Institute for Nature and Forest, Flemish Govt
specified as a JSON object passed via stdin to qgis_process This provides a mechanism to support complex input parameters for algorithms, and a way for qgis_process to gain support for parameter types which are themselves specified as a dictionary type object. To indicate that parameters will be specified via stdin then the qgis_process command must follow the format qgis_process run algid - (with a trailing - in place of the usual arguments list). The JSON object must contain an "inputs" key, which is a map of the input parameter values. E.g. echo "{"inputs": {\"INPUT\": \"my_shape.shp\", DISTANCE: 5}}" | qgis_process run native:buffer - Specifying input parameters via stdin implies automatically the --json output format for results. One big motivation behind this enhancement is to provide a way for the qgisprocess R libraries to support parameter types such as aggregates. Refs r-spatial/qgisprocess#56 Refs r-spatial/qgisprocess#44 Sponsored by the Research Institute for Nature and Forest, Flemish Govt
This issue was solved a whole time ago - solution demonstrated with reprex in #74 (comment). |
I'm not so experienced with QGIS and
qgisprocess
, so the below problem may be a demonstration of just that...According to #13 work is still needed to support the 'aggregates' argument type; it mentions
rlang::quo()
so I wondered whether something can be done in below code to make it work already. Purpose below is the same as doingsf::st_union(object)
, I'm only interested in the single aggregated object, not in attributes. It works when done interactively using the QGIS GUI.Processing parameters from the QGIS GUI log:
Session info
The text was updated successfully, but these errors were encountered: