I want to perform raster smoothing on a DEM file. I want to to assign the elevation of each pixel using the average elevations of its 8 neighbors. The ESRI's "Python scripting for ArcGIS" has a chapter on using python for raster but it did not help me to write a code for this. I'm looking for any useful literature, tutorial, or sample code...! please note that r.buffer and r.neighbors is not a good answer for me since I want to learn how to write this code completely.
Using the Python GDAL bindings, you should simply update this example:
- use from osgeo import gdal instead of import gdal
- import numpy (to be installed) instead of Numeric;
- adapt the outData[i,j] expression to your need, simply changing the coefficients;
- some cosmetic corrections in the print messages and...
- above all, thanks Chris Garrard, the author of the Geoprocessing with Python using Open Source GIS courses.