2

I have a raster consisting of integer values in each cell. I want to check every adjacent cell in a 3x3 grid to see if any one of the adjacent cells has a value EQUAL to the center cell, and if so, give the output raster a value of 1 (else give it a value of 0). I have already accomplished this like so:

Con("raster" == FocalStatistics("raster", NbrIrregular("C:\filepath\kernel_file.txt"), "MAXIMUM"), 1, 0)

Where the kernel file looks like this:

3 3 
1 0 0
0 0 0
0 0 0 

Then again for another possible combination:

3 3 
0 1 0
0 0 0
0 0 0

And so forth:

3 3 
0 0 1
0 0 0
0 0 0 

Then I have to combine all of the rasters at the end to get one final raster.

Is there a more efficient way to accomplish this? It shouldn't be necessary to loop through the raster this many times to get what I need. Raster calculator solutions will work, but ArcObjects solutions are welcome as well as the end result will likely end up being implemented in ArcObjects.

2

The focal variety (in a 3 by 3 neighborhood) remains the same when the center is not used (for a focal variety in an annular 3 by 3 neighborhood) if and only if the center cell is duplicated in one of the neighboring positions. This solution requires just two neighborhood calculations and a comparison.

protected by Community Aug 1 '16 at 21:57

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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