HOW TO

Calculate the maximum difference between a grid cell and it's neighbours

Last Published: April 25, 2020

Summary

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.

Procedure



  1. Create a text file (any_name.txt) with the following four lines:

       3 3
    1 1 1
    1 0 1
    1 1 1

    Make sure you type a return after the last number.

  2. Determine the maximum and and minimum values around the cell.

    Code:
    Grid: fmax = FOCALMAX (in_grd, IRREGULAR, donut.txt)
    Grid: fmin = FOCALMIN (in_grd, IRREGULAR, donut.txt)

  3. Determine the difference between the cell and the max/min values.

    Code:
    Grid: diffmax = ABS (fmax - in_grd)
    Grid: diffmin = ABS (in_grd - fmin)

  4. Assign the maximum difference to the output grid.

    Code:
    Grid: finaldiff = MAX (diffmax, diffmin)

Article ID:000002114

Software:
  • ArcMap 8 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options