2

I'm trying to create a QGIS script that would use multiple Raster layers as an input parameter. But QgsProcessingParameterRasterLayer only gives a single Raster as input and QgsProcessingParameterMultipleLayers defaults to a multiselect of Vector layers.

I'm probably missing something easy, but how can I get the multiselect to work with raster files like the Merge Rasters tool does for example?

Taras
35.8k5 gold badges77 silver badges151 bronze badges
asked Oct 14, 2021 at 9:55

1 Answer 1

3

Just pass the QgsProcessing.SourceType to the QgsProcessingParameterMultipleLayers class constructor:

def initAlgorithm(self, config=None):
 self.addParameter(QgsProcessingParameterMultipleLayers(
 self.INPUT,
 self.tr("Input rasters"),
 QgsProcessing.TypeRaster))
answered Oct 14, 2021 at 11:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.