Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I would like to use a nearest-neighbor type analysis to iterate over a raster. The nearest neighbor analysis will give a cell value of 1 IF AND ONLY IF the cell being analyzed has a cell value larger than all adjacent cells, and 0 otherwise. Is this type of analysis possible with Arcobjects or with the raster calculator tool using map algebra?

share|improve this question
What software would you prefer to use? ArcGIS Spatial Analyst or ArcObjects? I would expect this to be easy with the Raster Calculator of Spatial Analyst so am wondering whether you have tried that without success. –  PolyGeo Apr 26 '13 at 23:33
I am testing this statistical methodology as part of a raster extraction process for an automated ArcObjects implementation. I wanted to see if the statistical methodology provides the desired results without ArcObjects if possible first (it didn't unfortunately), so in this case Luke's ArcGIS Spatial Analyst implementation worked best for me. Thank you for your input. –  Conor Apr 27 '13 at 0:55

1 Answer 1

up vote 1 down vote accepted

Use the Con and FocalStatistics tools. Something like:

Con(inraster > FocalStatistics(inraster, NbrIrregular(kernel_file), "MAX", ""), 1, 0)

Where: kernel_file is a path to a text file that defines a neighbourhood that excludes the currently processed cell, something like:

3 3
1 1 1
1 0 1
1 1 1

You might also be able to do this with an annulus neighbourhood, but I can't test as I'm not at work.

share|improve this answer
You are the hero that this forum needs. –  Conor Apr 27 '13 at 0:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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