I have several GeoTIFFs that I'm working with to create contours using gdal_contour. One of them crashes the utility. gdalinfo tells me that the computed min values for band 1 and 2 are -340282346638528860000000000000000000000... This seems to be creating the problem as none of the others are so irrational (think in the single digit range / near sea-level).

Is there a way to "fix" this geotiff by replacing anything below 0 with a reasonable value such as 1 or even 0? And can I simultaneously replace "nodata" values with 0 or 1?


gdal_Calc.py can do that, a reclass

Something like..

gdal_calc.py -A filename.tiff --outfile=filename.tiff --calc="A*(A>3)" --NoDataValue=0 --calc="1*(A<3)

See this one

gdal_calc.py raster reclass equivalent of ArcGIS reclass or r.reclass in grass

| improve this answer | |
  • Thanks! Got it to work with: gdal_calc.py -A filename.tiff --outfile=filename.tiff --calc="A*(A>3)" --NoDataValue=0 (what is the second --calc attribute for? I didn't end up using it) – clayperez Sep 21 '14 at 3:12
  • is is just a sample, it changes the other values to 1 – If you do not know- just GIS Sep 21 '14 at 13:02

If the min value is consistent - like a no data value, you might be able to use the snodata option and specify the value you want ignore. As listed in the doc for gdal_contour

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