Take the 2-minute tour ×

I am looking for some advice on how to calculate the distance from a point to a different class of a raster. Specifically, I have observations (points) of animal use overlaid on land cover data. For each point I want to calculate the distance to the nearest cell of a different cover type. For instance, if a point is located in a grassland patch, what is the distance to the nearest cell that is not grass. I am using ArcGIS 10 and have a spatial analyst license.

I think raster calculator might be the best approach for this- could anyone provide an equation that would accomplish this?

Thanks in advance!

share|improve this question

1 Answer 1

up vote 7 down vote accepted

I don't believe there's a single command to do this, but we can still accomplish it expediently. The idea is that the distance to the nearest different cell equals the distance to the nearest location whose immediate neighborhood contains more than one cell type.

Well, this is not quite true, but it's close: you might want to add approximately one cell width to such a distance. If you can live with such an approximation, here's the workflow:

  1. Compute a focal variety grid using as small a neighborhood as possible, which would be a 2 by 2 square neighborhood.

  2. Nullify all locations with a focal variety of 1 or less: these are the "inside" cells.

  3. Compute the Euclidean distance grid to all remaining cells: these are the distances to locations along boundaries.

  4. (Optional) Add the cellsize to the distance grid.

  5. Extract the values at any points you choose.

To illustrate, here is a small piece of a grid colored by cell type. The black areas are the cells with focal varieties of 2 or greater (computed at step 2):

Cell classes

A hillshaded Euclidean distance grid looks like this:

Distance grid

It reaches peaks (maximum values) within the centers of each patch of the original raster and decays to zero along the patch boundaries, still shown with black.

share|improve this answer
That's exactly what I needed! Thanks for the quick response and clear explanation. –  James Feb 18 '13 at 23:06

Your Answer


