[Qgis-user] Using raster layer bands in map calculator in graphical modeler

Paulo van Breugel p.vanbreugel at gmail.com
Sun Mar 25 02:11:52 PDT 2018


Hi,

I have a multiband raster layer 'myraster.jp2'. Now I want to build a model
in the graphical model builder, with as user input the raster layer, and
the raster calculator to compute the NDVI.

Suppose I have the multiband raster layer loaded in QGIS as 'myraster',
then I can use the following expression in the raster calculator:

"myraster at 1"+"myraster at 2"

This works when the name of the raster is 'hard coded', but what if I want
the user to select the layer (or file) when running the model?

I can add a 'raster layer' to the model, and use that as input in the
raster calculator. That will show up in the layer selction box of the map
calculator. When selecting that, it shows in the expression box as:

"<qgis._core.QgsProcessingModelChildParameterSource object at
0x0000023D82087948>@1"

See screenshot:
https://www.dropbox.com/s/g1o5ikxufkordkq/screenshot.png?dl=0

Running a model with this as input in the raster calculator results in an
empty raster layer.

Any idea how I can use raster calculator in the model builder whereby the
raster layer can be selected by the user?

Best wishes,

Paulo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20180325/a8e80c81/attachment.html>


More information about the Qgis-user mailing list