<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to do Simple Update of Point Attributes from Polygon where Intersects? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-do-simple-update-of-point-attributes-from/m-p/681624#M52804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;I don't want a new/separate layer for each spatial join that would then need to be merged together&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;I don't want all the fields back from the polygon boundary, usually just 1.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;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.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Ideally a quick update in place like a UpdateCursor with spatial intersects function would be great!&amp;nbsp; Like SQL Spatial does. (See below)&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;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.&amp;nbsp; This works good as a work around.&amp;nbsp; 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.&amp;nbsp; Would like to stay within the file geodatabase where all the other processing is done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should be something similar and simple as all the SQL Spatial geometry functions in ArcGIS/Python.&amp;nbsp; Haven't been able to find anything in update cursors or geometry functions that will do this very basic, yet powerful, GIS operation.&amp;nbsp; Anybody know of anything?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example in SQL Spatial, quick field update where point intersects Congressional District...then intersect with the next boundary.&amp;nbsp; Where is this in Python?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
UPDATE r SET
r.CONGRESS_DIST = s.DISTRICT
from eGIS.AddressPoints r, eGIS_Spatial.eGIS.CA_CONGRESSIONAL_DISTRICTS_2011 s&amp;nbsp; 
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&amp;nbsp; 
where 
s.Shape.STIntersects(r.Shape) = 1

...

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 17 Oct 2013 22:15:01 GMT</pubDate>
    <dc:creator>TomWeisenberger</dc:creator>
    <dc:date>2013-10-17T22:15:01Z</dc:date>
    <item>
      <title>How to do Simple Update of Point Attributes from Polygon where Intersects?</title>
      <link>https://community.esri.com/t5/python-questions/how-to-do-simple-update-of-point-attributes-from/m-p/681624#M52804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;UL&gt;&lt;BR /&gt;&lt;LI&gt;I don't want a new/separate layer for each spatial join that would then need to be merged together&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;I don't want all the fields back from the polygon boundary, usually just 1.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;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.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;Ideally a quick update in place like a UpdateCursor with spatial intersects function would be great!&amp;nbsp; Like SQL Spatial does. (See below)&lt;/LI&gt;&lt;BR /&gt;&lt;/UL&gt;&lt;SPAN&gt;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.&amp;nbsp; This works good as a work around.&amp;nbsp; 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.&amp;nbsp; Would like to stay within the file geodatabase where all the other processing is done.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Should be something similar and simple as all the SQL Spatial geometry functions in ArcGIS/Python.&amp;nbsp; Haven't been able to find anything in update cursors or geometry functions that will do this very basic, yet powerful, GIS operation.&amp;nbsp; Anybody know of anything?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example in SQL Spatial, quick field update where point intersects Congressional District...then intersect with the next boundary.&amp;nbsp; Where is this in Python?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
UPDATE r SET
r.CONGRESS_DIST = s.DISTRICT
from eGIS.AddressPoints r, eGIS_Spatial.eGIS.CA_CONGRESSIONAL_DISTRICTS_2011 s&amp;nbsp; 
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&amp;nbsp; 
where 
s.Shape.STIntersects(r.Shape) = 1

...

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Oct 2013 22:15:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-do-simple-update-of-point-attributes-from/m-p/681624#M52804</guid>
      <dc:creator>TomWeisenberger</dc:creator>
      <dc:date>2013-10-17T22:15:01Z</dc:date>
    </item>
  </channel>
</rss>

