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 but could anyone provide an equation that would accomplish this?

1 Answer 1


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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