3

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.

3
  • 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. Commented Mar 8, 2017 at 5:37
  • That worked, thanks. I'm pretty n00bish with python.
    – jfact0ry
    Commented Mar 8, 2017 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. Commented Mar 8, 2017 at 5:50

1 Answer 1

3

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).

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.