2

I'm trying to use the graphical modeller to automate a certain process (extracting North-South facing slopes from a DEM).

The process is as follows:

  1. Calculate Slope
  2. Calculate Aspect
  3. Extract North-South Slopes using the raster calculator expression:
Slope*cos((3.141592/180)*Aspect)^2

This works flawlessly when I do it step by step, using the default Processing toolbox raster calculator, Slope and Aspect.

When I try to input this in the Graphical modeller however I get an error: "pointer cannot be cast to type 'float'"

The aspect and slope are calculated as expected, but the raster calculator fails.

I've tried this in QGIS 3.8 and 3.10.

I've tried assigning the CRS to the slope and aspect layers before the calculation, and tried using the GDAL calculator (which returns a "TypeError").

My question is: What am I doing wrong here? The same steps work perfectly outside the graphical modeller, so I don't see why they should fail here.

Graphical Modeller

Error

4
  • Correct me if I'm wrong: Doesn't the calculator require a geographical extent? Which then may be has to be set automatically?
    – Erik
    Dec 10, 2019 at 11:57
  • It does. The extent, CRS, and cellsize are taken from the reference layers. The reference layers are the input Aspect and Slope layers. This works outside the graphical modeler. I've also tried manually assigning it, or using the DEM as the reference layer, but that does not solve the issue.
    – mzedp
    Dec 10, 2019 at 12:00
  • I am not able to reproduce this. The correct way to reference layers in formula is Slope@1, Aspect@1 etc. I have created a model and it works fine in 3.10. The raster calculator formula is 'Slope@1*cos((3.141592/180)*Aspect@1)^2' and selected both slope and aspect as reference layers. Dec 10, 2019 at 12:02
  • Thank you @spatialthoughts. Im sure the layer reference is correct (Im double clicking from the layer list to input them into the expression, the actual references I'm getting are "'Aspecto' from algorithm 'Aspect'@1", I shortened to just Aspect for readability). What reference layers are you using for extent/CRS/cellsize?
    – mzedp
    Dec 10, 2019 at 12:16

1 Answer 1

2

I've just managed to get the model working.

The issue is caused by a glitch of some sort, related to the system language. After changing the QGIS language from Spanish to English, the model above works with no issues. Will report this on the QGIS github. (bug report)

It's not the first time I've run across issues during some process due to the language, so I'd recommend keeping QGIS in English, as it seems to be more stable.

1
  • Glad you figured it out and took the time to make a bug report. Would you mind adding the link to the bug report to your answer?
    – csk
    Dec 10, 2019 at 16:56

Your Answer

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

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