Averaging fields from neighboring 1km grid polygons

3139
6
Jump to solution
09-29-2015 08:24 AM
BenjaminSimpson
New Contributor III

Hi all,

I have a 1km grid layer which contains results on nitrate leaching from a model run. Ultimately what I need to do is average the nitrate concentrations for all of the 1st order neighbors and the central polygon for all of the polygons in my layer. I am not sure how to go about this in ArcMap.

I am using ArcGIS 10.3 on Windows 7.

The 1km grid polygon layer contains x and y coordinates for the centroids of each 1km grid and a unique ID for each 1km grid.

Any help on how to do this would be much appreciated.

Thanks,

Ben.

0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

I think you're bound to using a vector solution for this. Luckily, something very similar came up yesterday: Re: Creating variables indicating adjacent sectors

Once you've done the self-Spatial Join, run Summary Statistics using MEAN as the statistic on the field for which you want the averages, and Target_FID as the case field.

View solution in original post

6 Replies
ChrisDonohue__GISP
MVP Alum

For clarification, can you explain what is a "1st order neighbor"?  Is that a spatial relationship, like polygons touching it, or a relationship of nitrate concentrations?  Do you need an iterative process to do all your polygons or just a single process that does the central polygon and what is immediately around it?

Also, if you have a diagram or figure that shows what you are trying to do, can you post it?

Chris Donohue, GISP

0 Kudos
BenjaminSimpson
New Contributor III

The 1st order neighbors are all the polygons touching the central polygon.So the maximum number of polygons being averaged for a single polygon would be 9 (including the central polygon). This needs to be done for every polygon within the layer.

Diagram showing a source polygon and its neighbor polygons

The image above best represents what I am looking for, so all the none white polygons would have their nitrate concentrations averaged and that averaged value would be assigned to the central polygon. The same process would be done on all the polygons regardless if they have already been used for calculating the average of another polygon.

Hope that better explains it.

Thanks,

Ben.

0 Kudos
ChrisDonohue__GISP
MVP Alum

Thanks, that helps provide a better idea of what you are looking for.  My initial thought is that you could do a "moving window" analysis with the data as raster, as that is a common process.  However, that said, I haven't done one that way in a few years and have to scratch my head a bit to remember it.  I'll see if I can recall the process; meanwhile there are a whole slew of folks here on GeoNet who know this by heart.  Here's a few of them:

Dan Patterson

Darren Wiens

Chris Donohue, GISP

0 Kudos
DarrenWiens2
MVP Honored Contributor

I think you're bound to using a vector solution for this. Luckily, something very similar came up yesterday: Re: Creating variables indicating adjacent sectors

Once you've done the self-Spatial Join, run Summary Statistics using MEAN as the statistic on the field for which you want the averages, and Target_FID as the case field.

ChrisDonohue__GISP
MVP Alum

If you have access to the Spatial Analyst Extension, you can use Focal Statistics (Spatial Analyst) to accomplish what you need:

ArcGIS Desktop

If you don't have access to the Spatial Analyst Extension and/or want to work entirely in the vector world, you could set up an iteration in either Modelbuilder or Python to loop through all the polygons.  First it would Select By Location the surrounding polygons.  Then it would Calculate Field the average of all the selected and write it to a field.  Note that the Calculate Field function will need to draw upon the number of selected records to correctly calculate the average, as this can vary (example:  corner polygon).

ArcGIS Desktop

Chris Donohue, GISP

DanPatterson_Retired
MVP Emeritus

Chris Donohue​ and Darren Wiens​ suggestsions are all valid.  If the grids spacing and locations are as irregular as your image shows, I would try the polygon solution first since the spatial analyst will impose an   regular grid over the extent.  You don't actually indicate the location pattern of your core polygons, which may be of interest.  It is possible to generate a sparse array from widely spaced core cells for which there is surrounding data.  Should you have the time to show an enlarged area image it might solicit other suggestions which you could examine after the other suggestions are examined.