<?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: nearest feature to a given point in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194486#M14925</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/generate-near-table.htm"&gt;Generate Near Table&lt;/A&gt;.&amp;nbsp; Put the table in-memory and then use a cursor to loop through it looking for FIDs.&amp;nbsp; The original table stays intact.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 04 Mar 2017 17:12:03 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2017-03-04T17:12:03Z</dc:date>
    <item>
      <title>nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194483#M14922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am looking for a python code to find the nearest feature (street layer) for any given point (x,y) on the map.&amp;nbsp;&lt;/P&gt;&lt;P&gt;i need to return the&amp;nbsp;feature id only.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#python&amp;nbsp;#arcpy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 12:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194483#M14922</guid>
      <dc:creator>Faris_TawfiqAbdelFattah</dc:creator>
      <dc:date>2017-03-02T12:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194484#M14923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ArcInfo level license: use the Near tool.&lt;/P&gt;&lt;P&gt;Basic level license: perhaps start with a spatial join and go from there?&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 17:23:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194484#M14923</guid>
      <dc:creator>JimCousins</dc:creator>
      <dc:date>2017-03-02T17:23:29Z</dc:date>
    </item>
    <item>
      <title>Re: nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194485#M14924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks a lot Jim.&lt;/P&gt;&lt;P&gt;the near tool will add fields to the layer used, am looking for another way which will return only the FIDs &amp;nbsp;so i can loop through them and read information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;something like featurecursor interface in arcobjects.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks again for your replay.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Mar 2017 09:11:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194485#M14924</guid>
      <dc:creator>Faris_TawfiqAbdelFattah</dc:creator>
      <dc:date>2017-03-04T09:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194486#M14925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/generate-near-table.htm"&gt;Generate Near Table&lt;/A&gt;.&amp;nbsp; Put the table in-memory and then use a cursor to loop through it looking for FIDs.&amp;nbsp; The original table stays intact.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 04 Mar 2017 17:12:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194486#M14925</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-03-04T17:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194487#M14926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Joshua ,&lt;/P&gt;&lt;P&gt;i tried the tool, it does not take a point object (it needs a feature layer as an input). i need to let the user input &amp;nbsp;the point coordinates in order to search the nearest feature and return its information.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;unfortunately the two methods (near_analysis, generate near table) are not helping.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Mar 2017 07:07:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194487#M14926</guid>
      <dc:creator>Faris_TawfiqAbdelFattah</dc:creator>
      <dc:date>2017-03-05T07:07:24Z</dc:date>
    </item>
    <item>
      <title>Re: nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194488#M14927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use a point they created.&amp;nbsp; It sounds like you need to code the ability for&amp;nbsp;a person to enter a point first then run one of those two analysis options.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Mar 2017 09:25:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194488#M14927</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-03-05T09:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194489#M14928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As is the case with most geoprocessing tools, the &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;in_features&lt;/SPAN&gt; can be ArcPy Geometry objects in addition to feature layers.&amp;nbsp; In your case, create a &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-classes/pointgeometry.htm"&gt;PointGeometry &lt;/A&gt;object for the coordinates you want, and then pass that point geometry as the &lt;SPAN style="font-family: courier new,courier,monospace;"&gt;in_features&lt;/SPAN&gt; to the Generate Near Table tool.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 05 Mar 2017 15:00:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194489#M14928</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-03-05T15:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: nearest feature to a given point</title>
      <link>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194490#M14929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Joshua , Dan and JIM&lt;/P&gt;&lt;P&gt;Finally i created the tool which without your suggestions i couldn't make it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def Closest_RD_XY( X, Y, Near_FC , Meters &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt; try:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; SR = arcpy.SpatialReference(4326)# WGS84 GCS&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;pntFC = arcpy.CreateFeatureclass_management("in_memory", "Acc_FC", "POINT", spatial_reference = SR)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;# Just to check if layer created or not &lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;if pntFC is None:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;print "FeaClass 'Acc_FC' is not created"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;#-------------------------------------------&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;In_curs = arcpy.da.InsertCursor( pntFC , ["SHAPE@XY"])&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;INValue = In_curs.insertRow([(X, Y)])&amp;nbsp;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if INValue &amp;lt; 1 : print "point is not inserted"&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;del In_curs&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;# use the near tool in arcpy&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.Near_analysis(pntFC, Near_FC , str(Meters)+ " Meters", "LOCATION","ANGLE","GEODESIC")&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;S_curs = arcpy.da.SearchCursor(pntFC, "*") &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;RD_ID = S_curs.next()&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;# return all information of the nearest feature&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;SN_curs =arcpy.da.SearchCursor(Near_FC, "*", "OBJECTID = " + str(RD_ID[2]))&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;NFeature = SN_curs.next()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;#delete in memory point layer &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.Delete_management (pntFC)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return NFeature&lt;/P&gt;&lt;P&gt;except Exception as e:&lt;BR /&gt; return "Error No Road found within 100 Meters 'Error ': " + e.message&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Mar 2017 07:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/nearest-feature-to-a-given-point/m-p/194490#M14929</guid>
      <dc:creator>Faris_TawfiqAbdelFattah</dc:creator>
      <dc:date>2017-03-27T07:07:28Z</dc:date>
    </item>
  </channel>
</rss>

