4

I'm looking to automate a procedure that will change a single cell value in a raster. I have a known x, y and z, and a raster. I need to change the cell value (closest to my x and y value) to the specified z value.

I've been doing this using Saga (change cell values [interactive] module) but I need a more automated method for use in a batch file or python script. MI thought there may be a module for updating a raster cell based on point (vector) values?

Note, I do not want to reclassify grid values, rather I wish to specify one.

I have access to QGiS, Saga and ArcGIS basic (without any spatial or 3D packages).

1 Answer 1

4

Since you are looking for an automated method using Python, I recommend the GDAL libraries. If you are on windows I highly recommend the gisinternals repository for the binaries.

I'm guessing you are not familiar with the GDAL libraries and how to do raster processing with them (hence your question), so here is a tutorial. For raster processing, start at tutorial 4, and by the time you have read through tutorial 6 you will have the knowledge.

Essentially, the GDAL libraries, in conjunction with NumPy read the raster into an array which you can then manipulate as required. Once the raster is an array, you can change values in individual cells, work on blocks of cells, apply filters, etc. The tutorials will get you started but for some big intense processes I also recommend using the ndimage modules from SciPy - but for your purpose the NumPy methods described in the tutorial will be sufficient (you cue when to use SciPy is when raster processing gets tediously slow using NumPy).

Not the answer you're looking for? Browse other questions tagged or ask your own question.