<?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: Get distance from X / Y coordinates from xls Excel file in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743209#M291</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I forgot an important information. The distance should be calculated via a Routing service (Street Map Premium or ArcGIS Online).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Jun 2020 13:14:54 GMT</pubDate>
    <dc:creator>ChristianBischof</dc:creator>
    <dc:date>2020-06-22T13:14:54Z</dc:date>
    <item>
      <title>Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743207#M289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a xls Excel file with a startpoint and endpoint column each containing x and y coordinates and I need to get the distance between each start- and endpoint. The result (the calculated distance) should be added as new column into the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anybody help me out here with python code snippet or a workflow to achieve this?&lt;/P&gt;&lt;P&gt;Thanks in advance &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2020 12:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743207#M289</guid>
      <dc:creator>ChristianBischof</dc:creator>
      <dc:date>2020-06-22T12:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743208#M290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Basic 10th grade geometry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a² + b² = c²&lt;/P&gt;&lt;P&gt;Where c is the line between&amp;nbsp; a and b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or simply&amp;nbsp; create lines from the coordinates and populate your spreadsheet with the shape length resulting from the lines&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2020 13:05:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743208#M290</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2020-06-22T13:05:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743209#M291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I forgot an important information. The distance should be calculated via a Routing service (Street Map Premium or ArcGIS Online).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2020 13:14:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743209#M291</guid>
      <dc:creator>ChristianBischof</dc:creator>
      <dc:date>2020-06-22T13:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743210#M292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep whole new level of complex.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We don't use routing services ourselves.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But what you could do is build the points in the gis and add a hyperlink using Google, Apple, or Bing maps to create the driving directions when you select the hyperlink.&amp;nbsp; It would at least give you the best route based on traffic.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used just that when creating driving directions into Collector (before Collector had directions built in)&lt;/P&gt;&lt;P&gt;The field techs would click the hyperlink and it would pop up Google or Apple maps to give directions to the site they were going to.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2020 13:21:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743210#M292</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2020-06-22T13:21:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743211#M293</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My approach would look something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd apply the tools in ArcGIS Pro and get the basic Python code from it, but I'm new to ArcGIS Pro and don't know which tools to use.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2020 13:39:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743211#M293</guid>
      <dc:creator>ChristianBischof</dc:creator>
      <dc:date>2020-06-22T13:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743212#M294</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just use the same tools you would use for ArcMap&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2020 14:18:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743212#M294</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2020-06-22T14:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743213#M295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/405468" target="_blank"&gt;Christian Bischof&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;Here's the python code which takes an excel file with&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;a startpoint and endpoint column each containing x and y coordinates as input and outputs an excel file with shape_length (distance) calculated in a new column.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Just change the variables' values, sheet name and the &lt;SPAN style="color: #333333; background-color: #f7f7f7; text-decoration: none; font-size: 13px;"&gt;spatial_reference&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="" style="color: #b27d12; background-color: transparent; font-weight: bold; text-decoration: none; font-size: 13px;"&gt;&lt;/SPAN&gt;accordingly it should work.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; pandas &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; pd

excelTable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\temp\XY_Coordinates.xlsx"&lt;/SPAN&gt;
csvTable &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\temp\out_csv.csv"&lt;/SPAN&gt;
outputFC &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\temp\output.gdb\out_coordinates"&lt;/SPAN&gt;
out_Excel &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\temp\XY_Coordinates_output.xlsx"&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;
read_file &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; pd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;read_excel &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;excelTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sheet_name&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'Sheet1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
read_file&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;to_csv &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;csvTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; index &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; header&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Convert x and y coordinates into line&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;XYToLine_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
    csvTable&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
    outputFC&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
    &lt;SPAN class="string token"&gt;'Start_X'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
    &lt;SPAN class="string token"&gt;'Start_Y'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
    &lt;SPAN class="string token"&gt;'End_X'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
    &lt;SPAN class="string token"&gt;'End_Y'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
    &lt;SPAN class="string token"&gt;'NORMAL_SECTION'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
    '&lt;SPAN class="comment token"&gt;#', &lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;"PROJCS['GDA_1994_MGA_Zone_50',GEOGCS['GCS_GDA_1994',DATUM['D_GDA_1994',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',10000000.0],PARAMETER['Central_Meridian',117.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]];-5120900 1900 10000;-100000 10000;-100000 10000;0.001;0.001;0.001;IsHighPrecision"&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Converting gdb feature class attribute to Excel&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TableToExcel_conversion&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;outputFC&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; out_Excel&lt;SPAN class="punctuation token"&gt;)&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;/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;Here's a screenshot of the output:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="499346" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/499346_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:37:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743213#M295</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-12-12T07:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Get distance from X / Y coordinates from xls Excel file</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743214#M296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/360701"&gt;Mehdi Pira&lt;/A&gt;‌ !&lt;/P&gt;&lt;P&gt;This is definitely a way in the right direction. Although I forgot to mention, that I need to calculate the distances based on a street network (SMP) and the results from your approach are direct lines between the points, right?&lt;/P&gt;&lt;P&gt;Thank you anyway for the "Excel Hint" this was also very helpful!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anybody could suggest if I should rather try to implement a solution with ODCM Matrix or CF, maybe just a Route? The only thing we need is the distance in km.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jul 2020 08:32:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/get-distance-from-x-y-coordinates-from-xls-excel/m-p/743214#M296</guid>
      <dc:creator>ChristianBischof</dc:creator>
      <dc:date>2020-07-07T08:32:01Z</dc:date>
    </item>
  </channel>
</rss>

