My question is very similar to Summing up values of neighbouring polygons using QGIS?. However, I would like to be able to perform the analysis within ArcGIS Desktop if possible.

What I would like to do is calculate the percentage of blocks containing animal sightings surrounding a block and add the sum as a new field.

Delaware Atlas Grid

For example If we look at block 1 it is surrounded by 6 other blocks (224,2,7,6,5, and 227). The blocks that are highlighted in yellow are the blocks that actually contain animal sighting data. Block 1 has 1 neighboring block containing animal sightings; therefore, the new field I would like to add to block 1 would be .16 (1/6). Then we would move onto block 2 and perform the same calculation and so on.

I would have to perform this for different species and years and I seek ideas on how to automate this process.

  • You want to automate the process, so are you amenable to Python?
    – Tom
    Jun 11, 2019 at 15:56
  • I have taken a intro to python course hosted by ESRI, but that is about it. Jun 11, 2019 at 16:34
  • 1
    are you including the cell itself in the number? You would typically have 8 neighbors (9 total if you include the cell being calculated). Jun 11, 2019 at 18:32
  • I am not including the cell itself, just the surrounding cells. So 8 cells at most, but less for the ones on the outside edge. Jun 11, 2019 at 18:35
  • 3
    I suggest using polygon neighbor tool. Join original to output and summarize using src_fid.
    – FelixIP
    Jun 11, 2019 at 19:46

3 Answers 3


Here is how I would approach this. It does assume that you have the Spatial Analyst extension. I would first convert the vector grid to raster using the field that indicates the presence or absence of animal sightings. The result would be binary (1 or 0). I would make the cell size the same as the cells of the vector grid. Then I would run a focal sum filling out the tool as shown in the screenshot with a 3x3 grid. This WILL include the cell being calculated but we can deal with that in another step (continue below).

enter image description here

The second step then is to use the minus tool to subtract the original grid used as an input from the focal sum output (continued below).

enter image description here

That gives you a raster (or "grid") with a whole number indicating the number of neighbors. You can get this back to vector potentially if needed by getting the centroids of the vector grid (convert it to point) and extracting values from the grid (can even spatial join back to the original).

If you really need it as a percentage it is of course as easy as creating another field and dividing the whole number by the number of neighbors so you would need to manually calculate a field for that which you could do by assuming 8 and then fixing the edge cases?

  • That's the process that I would recommend too, but you have to make sure you set a snap raster for the conversion. That said, the OP is asking for a way to automate this across many datasets. Hopefully the OP uses this answer a basis for their code.
    – Tom
    Jun 11, 2019 at 20:03
  • Won't work because Count is not in a list of statistics. You'll need one more raster of 1, more operation s needed.
    – FelixIP
    Jun 11, 2019 at 22:54
  • Sum of one is a count Jun 12, 2019 at 12:40

You could do basic focal analysis with simple polygon fishnets and modelbuilder. Anything you can do with Toolbox functions or ArcPy can be automated in modelbuilder, which can be exported as an ArcPy script. For example I believe you could achieve your goal with a process of selections, buffering, spatial joins and dissolves.

As an example:

  • select out the polygons that have animal sightings into an animal sightings selection or layer

  • buffer them a small amount to ensure that the result will intersect with diagonal neighbors.

  • Select from neighbors by doing a spatial join from the buffered animal sighting polygons one-to-many. If the right parameters are provided in the spatial join you should get the neighbors with a join_count which should indicate how many animal sightings positive cells the neighbor intersected with.

  • A dissolve based on overlapping geometry and id should clear up duplicates of neighbors.
  • Finally a simple field calculation could calculate the ratio you described.

It may be more you may want to look into using ArcGIS Raster Calculator. It allows you to analyze multiple overlaying rasters and perform math on them, simple or complex. Your project sounds somewhat like Agent Based Modeling. I would definitely google it in conjunction with Wildlife Ecology Management, etc in case someone has already published a workflow that applies. Here is a guide that esri published about agent based modeling with Agent Analyst that might help you. Agent analyst likely requires extra licensing and the whole area of study may not apply to your ultimate goal. However, the text may be of interest because there seem to be some similarities with your description and many of the Agent Analyst workflow steps can actually be done with other esri tools like raster calculator.


  • I don't see how ABM comes into play. He simply wants to perform a basic focal analysis. Perhaps ABM is (or should be) his ultimate goal, but the question was much more basic. Let's not overwhelm him.
    – Tom
    Jun 11, 2019 at 18:22
  • 2
    Thanks for the feedback. I restructured accordingly. I can see where the area of ABM study might not be neccessary for the process described and could be overwhelming. It could also be enlightening and if one can begin to implement the techniques used to perform ABM in Arcgis, focal analysis workflows would be easier to conceptualize. Jun 11, 2019 at 22:37

I was able to use the polygon neighbor tool in ArcMap as recommended by @FelixIP. Using this tool in conjunction with an iterator in model builder was able to do the trick. Thanks to everyone who provided insight into this analysis.

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.