1

I want to use a script to do some raster calculations. I found this and this posts which seem to answer this question, however, it seems that they work for QGIS 2 and not for QGIS 3. I think the issues in QGIS 3 arise from using this line

qgis.utils.iface.legendInterface().layers()

which to my understanding gets each one of the layers in the project (each layer is defined as lyr in the loop here). In the second reference the layer is defined as bohLayer and i assume it was obtained in a similar way.

I tried using the path to a layer but obtained the following error

TypeError: str cannot be converted to qgis._core.QgsRasterLayer in this context

So my specific question is how can i call a layer in QGIS 3 to include it in a raster calculation (i.e. how to define lyr here or bohLayer here)?

Alternatively, a more general question is how to use the raster calculator from the console in QGIS 3?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.