0

I am programming a processing algorithm in PyQGIS that allows users to select certain natural protected areas from state-wide datasets that are stored in an internal data structure. The selection of objects for each layer is based on an intersection with an input polygon layer.

The user can define via an enum input whether the multiple output layers should be saved in Esri shapefile format or in a GeoPackage format. So far he/she can further only set the output file directory with QgsProcessingParameterFolderDestination.

Instead of the simply choosing the output folder directly, would it be possible to program a conditional input for either

  1. Esri shapefile: The output directory as currently used QgsProcessingParameterFolderDestination (current default)
  2. GeoPackage: Creation of a new GeoPackage or selection of an existing geopackage

This would give the user more control over the output GeoPackage (set a custom name or control overwriting)

2
  • Is this what you are looking for: QgsProcessingParameterFileDestination(name='OUTPUT', description=self.tr('TEST'), fileFilter='ESRI Shapefile (*.shp *.SHP);;GeoPackage (*.gpkg *.gpkg.zip *.GPKG *.GPKG.ZIP)') or it should only be the QgsProcessingParameterFolderDestination? The names in fileFilter were obtained from the list of filters after executing the QgsVectorFileWriter.fileFilterString(QgsVectorFileWriter.VectorFormatOptions()) Commented Aug 18 at 14:15
  • Well, this is indeed interesting too, but not really what I was looking for. For the tool the user can choose via an enum input whether the multiple output layers should be saved in a.) Esri shapefile format or in b.) Geopackage format. Depending on which enum the user chooses it would be nice to have an a.) QgsProcessingParameterFileDestination to define the folder where the multiple shapefiles are written into OR b.) QgsProcessingParameterFolderDestination to define the Geopackage where the multiple layers should be written into. Is it feasible to conditionally change the output option? Commented Aug 19 at 9:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.