1

I want to make a conditional branch in QGIS modeler based on the cell size of the incoming raster. If the cell size is larger than 10m, I would like to resample the raster to 10m before exporting it.

I am aware that one can add a conditional branch from Modeler tools->Conditional branch, from where you can define a Branch Name and a Condition. This Condition is implemented using the Expression Builder. But since the 'Rasters'-function group does not offer a quick method like 'cell size', there is no straightforward way of making a conditional.

From this question I found you can get the cell size by calling the rasterUnitsPerPixelX() method on a QgsRasterLayer object, but I have no clue how to implement that in a custom function, since the all the custom function examples I could find are using feature classes in stead of rasters.

So how can I make a conditional branch in the modeler based on the cell size of the incoming raster?

I'm using QGIS version 3.36.1

1 Answer 1

1
  1. Raster Layer Properties
  2. A conditional branch using @Raster_layer_properties_PIXEL_HEIGHT <=10 , or width. enter image description here
  3. Use each branch as a dependency to the next algorithm: enter image description here

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.