1

This question already has an answer here:

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.

P.S: I already took a look at this and this. they did not help me...may be since my knowledge is limited I need more comprehensive answer. Thanks in advance for any help you are able to provide.

marked as duplicate by Curlew, Paul, Fezter, Devdatta Tengshe, Jason Scheirer Oct 14 '13 at 2:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Using the Python GDAL bindings, you should simply update this example:

http://www.gis.usu.edu/~chrisg/python/2009/lectures/ospy_hw6a.py

Suggestions:

  1. use from osgeo import gdal instead of import gdal
  2. import numpy (to be installed) instead of Numeric;
  3. adapt the outData[i,j] expression to your need, simply changing the coefficients;
  4. some cosmetic corrections in the print messages and...
  5. above all, thanks Chris Garrard, the author of the Geoprocessing with Python using Open Source GIS courses.

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