0

I have a bunch of .img terrain files. To make sure the nodata value is consistent before layering them, I'm using this:

gdal_calc.py -A /path/infile.img --outfile=/path/outfile.img --calc="A*(A>=-1361)" --NoDataValue=-32768

That takes any non-sane value (the lowest elevation in the world is -1360) or anything currently set at the nodata value of -32768 and sets it to -32768.

However, some of the files have areas where the data is -0, which messes up the layering.

How can I include the -0 values in this: --calc="A*(A>=-1361)", so they get set to the new nodata value of -32768?

Basically --calc="A*(A>=-1361 | A='-0')" (which fails with invalid syntax).

user1517922
  • 1,308
  • 3
  • 15
  • 22

1 Answers1

0

I realize this is an older question but this answer describes floating point behaviour with negative zeroes.

Specifically, y+=0 should be sufficient to remove the negative zeros. This will likely require two passes of gdal_calc.py

Chris
  • 1,532
  • 10
  • 19
  • another pass of gdal_calc does it: gdal_calc -A temp.tif --outfile=temp_2.tif --calc="A + 0." --NoDataValue=-32768 – Leo Jul 11 '22 at 06:48