Sorry for the delay SUM. I'd like to Thank Lonnie Meinke for her scripts. She emailed me with three ave scripts for doing a moving window statistcs for grids. I modified her code a little bit and use NbrHood.MakeIrregular(theKernel) to calculate the average along the direction of the river. Below is part of the code: '*********** make the neighborhood****************************** firstLine = {1,0,0,0,0} secondLine = {0,1,0,0,0} thirdLine = {0,0,1,0,0} fourthLine = {0,0,0,1,0} fifthLine = {0,0,0,0,1} theKernel = {firstLine,secondLine,thirdLine,fourthLine,fifthLine} theNbrHood = NbrHood.MakeIrregular(theKernel) '***********Apply moving average******************************* Avgdgrid = g.FocalStats (#GRID_STATYPE_MEAN,theNbrHood,FALSE) '*************************************************************************** ****** You can make different kernels by changing the position of 1/0 in the matrix, and the average will be taken from the grid cell neighbour where the kernel has a value of 1. I think it will be nice if I can let the user to input the dimension of the grid and then let the user to fill in where the "1" and "0" are through dialogue boxes. But since I don't know much about avenue, I need to edit the script from the script boxes every time the river changes its direction of flow. If anyone interested in getting the script, email me. I've tried the 'convolution kernels' suggested by Nicholas Lindenberg in the ArcScript page before I posted my quesiton. It only applies filters to the grid like detecting edges but not calculating averages, so it is not good for my grids. Also, I need to convert my DEM into integer grid before I can use this extension. A. Benamghar suggested the 'moving windows statistics' script on the Arcscript page. I checked it and it is only good for shape files, not grids themes. Thanks for all your help! Eager =:o3 ipeager@interchange.ubc.ca ---------------------------------------------------------------------------- -------------------------------- My original question: I have some interpolated grids created from bathymetric point data of a > river. The grids will be used for generating contour maps. Regardless of > which interpolation methods are used, the interpolation often have 'holes' > along the deep areas and 'scalloped edges' along the river banks. Hence, > the contours generated will have tiny circles in these areas and I want to > remove them by smoothing the interpolated grids using 'directional > averaging'. That is, to calculate the mean of cell values using cells that > are parallel to the river; e.g. if river flows in the NE/SW direction, I > will have the kernel matrix like this: > > 0 0 1 > 0 1 0 > 1 0 0 > > and > the value of target cell > = Sum (cell value * kernel value)/ Sum (kernel) > > > I am looking for scripts/extensions that can do moving window statistics > in addition to mean, min, max, etc. that are already available in Spatial > Analyst. It will be great if the user can define the size of the moving > windows and the matrix used for the calculations (similar to Idrisi) ---------------------------------------------------------------------------- ----------------------------