I'm trying to return the values from a slope raster where the values = 0.

I am getting 'invalid syntax' returned. This is what I'm trying

gdal_calc.py -A slope.tif --outfile=result.tif --calc="A=0"

I'm trying gdal_calc.py because the internal QGIS calculator is only returning NaN values no matter what I do.

  • 1
    --calc="A=0" should return 1 for 0 and 0 for any other value, try --calc="A==0" as the logical (C like) test. Do you have any python ability? This wouldn't be too difficult to script as a python script using GDAL. – Michael Stimson Mar 8 '17 at 5:37
  • That worked, thanks. I'm pretty n00bish with python. – jfact0ry Mar 8 '17 at 5:48
  • Perhaps compile that into your own words and self-answer your question. I'm pretty sure that the docs gdal.org/gdal_calc.html are a bit hazy on the logic employed. – Michael Stimson Mar 8 '17 at 5:50

Shout-out to Michael Miles-Stimson for the solution.

gdal_calc.py -A slope.tif --outfile=result.tif --calc="A==0"

This produced essentially a binary raster from a slope raster where values were 0. gdal_calc.py was used because the raster was too large for the QGIS internal calculator (as far as I can tell).

|improve this answer|||||

Your Answer

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

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