3

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?

  • 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
  • 1
    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

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.

  • 1
    You are the hero that this forum needs. – Conor Apr 27 '13 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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