taweis

How to do Simple Update of Point Attributes from Polygon where Intersects?

Discussion created by taweis on Oct 17, 2013
Trying to find a simple solution in Python for what seems to be a GIS 101 operation: take a point and update its attributes, a new field, with information derived from its spatial relationship of a polygon boundary it falls within.

Basically I'm working on a script that geocodes addresses and then gets information about them spatially from various political and administrative boundaries (about 8).


  • I don't want a new/separate layer for each spatial join that would then need to be merged together

  • I don't want all the fields back from the polygon boundary, usually just 1.

  • I don't want to do a union of all my boundaries first into a big messy layer to do 1 spatial join and get all the results...then trim the fields down.

  • Ideally a quick update in place like a UpdateCursor with spatial intersects function would be great!  Like SQL Spatial does. (See below)

Best solution I have right now is to load the points into SQL Spatial/SDE and then call a stored procedure that uses the STIntersects function using pyodbc.  This works good as a work around.  While the intersect operation itself is pretty fast I'd rather not have to import and export from SQL Spatial/SDE just to do it there.  Would like to stay within the file geodatabase where all the other processing is done.

Should be something similar and simple as all the SQL Spatial geometry functions in ArcGIS/Python.  Haven't been able to find anything in update cursors or geometry functions that will do this very basic, yet powerful, GIS operation.  Anybody know of anything?



Example in SQL Spatial, quick field update where point intersects Congressional District...then intersect with the next boundary.  Where is this in Python?

UPDATE r SET
r.CONGRESS_DIST = s.DISTRICT
from eGIS.AddressPoints r, eGIS_Spatial.eGIS.CA_CONGRESSIONAL_DISTRICTS_2011 s  
where 
s.Shape.STIntersects(r.Shape) = 1

UPDATE r SET
r.PD_STATION = s.LABEL
from eGIS.AddressPoints r, eGIS_Spatial.eGIS.SHERIFF_REPORTING_DISTRICTS s  
where 
s.Shape.STIntersects(r.Shape) = 1

...

Outcomes