Want to create a 'spatial lag' variable on a polygon fishnet

371
1
10-25-2013 04:41 PM
NicholasSeltzer
New Contributor
Hello,
I have about 230 shapefiles which are polygon fishnets. For each fishnet there is a variable called 'foo' in the attribute table and each cell, or feature, has a value of 1 or 0. What I want to do is go through each shapefile and add a new variable 'bar' which is, for each feature, the count of the surrounding features where foo ==1. Could someone please explain to how to go about doing this, and if possible how it can be automated?

My purpose for doing this is to create a 'spatial lag'. When I'm done, I'm going to be exporting the attribute tables into Stata or R to conduct more traditional statistical analysis. If there is a simpler way or an existing tool that creates spatial lags in a more sophisticated way, please let me know.

Thank you so much for your help.

Nick
0 Kudos
1 Reply
TOMKONG
Occasional Contributor II
Only the thought:
1. Convert polygons to lines, and only select lines with "-1" value (lines between polygons);
2. Convert slected lines to the points (the central of the line), then intesect those ponits and original polygons to get intesected points;
3. In intesected point layer table (should have duplicate points -- intesected with same two polygons due to two polygon share mutipart lines, summarizing the line ID field,  and select First Polygon ID & Last Polygon ID; in the output table, create one new field to combinate First Polygon ID & Last Polygon ID fields, then summarizing this joined field to eliminate duplicates; 
4. Summarizing the polygon ID field from step 3 point layer (after eliminate duplicates) to get the sourrounding polygon count number, then join back to the original fishnet polygon layer.
0 Kudos