Thursday, 16 March 2017

raster - GDAL Changing Values



For context I am working with a .tif file that I have warped and changed all nodata values to -9999.


Is there any way with GDAL to take all values from this .tif file that are greater than -9999 and convert them to another value?


I have tired to do this with ogr2ogr but I don't know enough SQL to make that work.



Answer



Nodata value can be changed with gdalwarp utility:


gdalwarp -srcnodata "-9999" -dstnodata "0" original_raster.tif new_raster.tif

To change raster data (values greater then -9999 to 100) use calculator:


 gdal_calc.py -A original_raster.tif --outfile=new_raster.tif --calc="100*(A>-9999)+A*(A<=-9999)"

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...