How To: Calculate the maximum difference between a grid cell and it's neighbours
Using a 'kernal file' will restrict the analysis to the neighbours surrounding the cell currently being processed. Some simple mathematical evaluations will lead to the final result.
- Create a text file (any_name.txt) with the following four lines:
1 1 1
1 0 1
1 1 1
Make sure you type a return after the last number.
- Determine the maximum and and minimum values around the cell.
Grid: fmax = FOCALMAX (in_grd, IRREGULAR, donut.txt)
Grid: fmin = FOCALMIN (in_grd, IRREGULAR, donut.txt)
- Determine the difference between the cell and the max/min values.
Grid: diffmax = ABS (fmax - in_grd)
Grid: diffmin = ABS (in_grd - fmin)
- Assign the maximum difference to the output grid.
Grid: finaldiff = MAX (diffmax, diffmin)