[GIS] ENVI raster file with nodata change to 0

envigdalgdal-translate

I have a geotiff that I converted to a ENVI raster file with the following command:

gdal_translate -of ENVI srtm_05_08.tif data.bil

The geotiff has water values supposedly set to nodata. I am doing an interpolation on the data.bil file, and when I do, the water shows up at a height of about 32000m. I am wondering if there is a simple way to change the nodata to be 0. I tried:

gdal_translate -of ENVI srtm_05_08.tif data.bil -a_nodata none

and

gdal_translate -of ENVI srtm_05_08.tif data.bil -a_nodata 0.0

but neither of those seemed to work.

Is there an easy way to switch the data values? I could do something like:
if (val>5000) then val=0
but I am very much a beginner and don't know how to do it.

Best Answer

NODATA is a tag, not a value.

If you only need to attach NODATA to a different value you can try:

gdal_edit -a_nodata NEWVALUE input.tif

You strip away NODATA tag (always helpful) with:

gdal_translate -a_nodata none

Finally, if you need to actualy change the value and reattach NODATA to it, you might try something like this:

gdal_calc -A input.tif --outfile=output.tif --calc="255*(A==0)" --NoDataValue=255

You can modify --calc part to suit your needs, it supports many things.

Related Question