More

Can GDAL fill elevation below a certain value?

Can GDAL fill elevation below a certain value?


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


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