<?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 Re: Find a polygon for a single point in Python script in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827894#M3068</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't clearly understand the difference between ArcPy and ArcGIS API for Python.&lt;/P&gt;&lt;P&gt;Aren't they both using Python functions to get things automated which you can do manually in ArcGIS Pro ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 May 2018 14:28:55 GMT</pubDate>
    <dc:creator>MarcWouters</dc:creator>
    <dc:date>2018-05-30T14:28:55Z</dc:date>
    <item>
      <title>Find a polygon for a single point in Python script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827892#M3066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am writing a Python script in which I build a geodatabase, based on several inputs.&lt;/P&gt;&lt;P&gt;At one point, I am looping over a number of points (X,Y) which need to be treated individually&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;using several criteria.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;One criterium is the polygon in which this point is located. This polygon comes from a feature table with&amp;nbsp;a number of other fields.&lt;/P&gt;&lt;P&gt;There are several tools (Intersect, SelectByLocation, SpatialJoin, ....) which might help doing this, but they all are based on input and output tables.&lt;/P&gt;&lt;P&gt;How can I extract this one polygon, and linked fields, from that table, without having to make temporary input and output tables ?&lt;/P&gt;&lt;P&gt;In an ideal world, it could look like this :&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;for i in range (0, numberOfPoints):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; inputPoint = arcpy.Point(X, Y)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;findFeature(tableWithPolygons, inputPoint, outputFeature)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myValue = outputFeature.value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# based on this value, I can do further processing&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Thanks for pointing me in the right direction&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2018 14:11:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827892#M3066</guid>
      <dc:creator>MarcWouters</dc:creator>
      <dc:date>2018-05-30T14:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Find a polygon for a single point in Python script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827893#M3067</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does some part of this involve the ArcGIS API for Python or are you just using ArcPy, or aren't you sure?&amp;nbsp; I am sharing with &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;‌ since this seems to be ArcPy related.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2018 14:25:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827893#M3067</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-05-30T14:25:00Z</dc:date>
    </item>
    <item>
      <title>Re: Find a polygon for a single point in Python script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827894#M3068</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't clearly understand the difference between ArcPy and ArcGIS API for Python.&lt;/P&gt;&lt;P&gt;Aren't they both using Python functions to get things automated which you can do manually in ArcGIS Pro ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2018 14:28:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827894#M3068</guid>
      <dc:creator>MarcWouters</dc:creator>
      <dc:date>2018-05-30T14:28:55Z</dc:date>
    </item>
    <item>
      <title>Re: Find a polygon for a single point in Python script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827895#M3069</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See &lt;A href="https://community.esri.com/thread/187844-arcpy-api-vs-arcgis-python-api-eventual-deprecation-of-arcpy"&gt;https://community.esri.com/thread/187844-arcpy-api-vs-arcgis-python-api-eventual-deprecation-of-arcpy&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 May 2018 14:53:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827895#M3069</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-05-30T14:53:03Z</dc:date>
    </item>
    <item>
      <title>Re: Find a polygon for a single point in Python script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827896#M3070</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With the information provided, I can only provide a rough workflow that may or may not meet your needs:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;SR &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tableWithPolygons&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;spatialReference
layerPolygon &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tableWithPolygons&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"layerPolygon"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; range&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; numberofPoints&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; inputPointGeometry &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;PointGeometry&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Point&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;X&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;Y&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; SR&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SelectLayerByLocation_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layerPolygon&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"INTERSECT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; inputPointGeometry&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"NEW_SELECTION"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layerPolygon&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myValue &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# retrieve value(s) &lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;# based on this value, I can do further processing&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A few comments:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Tools like Intersect, Select By Location, Spatial Join work on geometries, so you will have to create a Point Geometry from your Point.&lt;UL&gt;&lt;LI&gt;To create a Point Geometry, you will have to (or really should) have a spatial reference.&amp;nbsp; My code above assumes the Point Geometry has the same spatial reference as the polygon layer.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;If you are going to be repeatedly executing spatial queries against a feature class, it is best to make a feature layer outside of the loop.&lt;/LI&gt;&lt;LI&gt;The code above assumes there may be more than one record returned from the spatial query.&amp;nbsp; If only one record is returned, at most, the code can be changed up a bit.&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:58:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827896#M3070</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T09:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: Find a polygon for a single point in Python script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827897#M3071</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Joshua,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for the late reply (I'm leaving my current position, and have lots of things to wrap up).&lt;/P&gt;&lt;P&gt;Thanks for the code snippet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've implemented your proposal (with a few modifications), and it works OK.&amp;nbsp;&lt;BR /&gt;Unfortunately I cannot avoid temporary layers.&lt;/P&gt;&lt;P&gt;It's quite time consuming (a query for every single point), but I cannot do it with the complete table, because the Intersect tool doesn't keep my features in the same order, and this is something I MUST have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2018 12:29:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827897#M3071</guid>
      <dc:creator>MarcWouters</dc:creator>
      <dc:date>2018-06-01T12:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find a polygon for a single point in Python script</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827898#M3072</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the polygon data set is already loaded into ArcMap as a layer, you don't need to create another layer, you can just use the already created one.&amp;nbsp; If the script is run outside of ArcMap, creating a feature layer in memory for processing isn't really an issue because the layer will go away when the script finishes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2018 14:05:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/find-a-polygon-for-a-single-point-in-python-script/m-p/827898#M3072</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2018-06-01T14:05:34Z</dc:date>
    </item>
  </channel>
</rss>

