<?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: finding shortest distance routes with python based on addresses in a file in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/finding-shortest-distance-routes-with-python-based/m-p/515534#M1704</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Olena,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Two things. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One, can you share your code for the routing task or direct me to where you found a good tutorial? I am trying to do something similar and can't figure it out quite yet. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Two, not sure if this will help but you could geocode the addresses first (i pasted the python code I use to geocode batches of address below). If there aren't too many addresses in your set you can then check out where they are on a base map and relocate those that are giving you trouble. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ramses&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python scripts to geocode batches of addresses:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'''&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Created on Aug 14, 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@author: rmadou&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This script geocodes batches of addresses&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To make this work you must add the geocoding service to ArcCatalog on your local machince. Here are instructions on how to do that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Look in the Catalog Tree for GIS Services.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Expand that and select Add ArcGIS Server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. In the dialog, choose Use GIS services. Click Next.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. For the Server URL, type: &lt;/SPAN&gt;&lt;A href="http://tasks.arcgisonline.com/arcgis/services"&gt;http://tasks.arcgisonline.com/arcgis/services&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;5. Press ok. You should now see arcgis on tasks.arcgisonline.com in that GIS servers list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6. Expand the connection and expand the locators folder. Select and click on the locator you want to use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7. Copy the full location path from the Location bar at the top of ArcCatalog. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you must also map your data headers to the GeocodeAddresses_geocoding headers &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for more information on the arcpy function/s used here see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/#/Geocode_Addresses/002600000006000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/#/Geocode_Addresses/002600000006000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;'''&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy,time, datetime&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#class Geocode():&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp; def RunGeoCoding(self):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;startTime = time.time()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "geocoding started at", datetime.datetime.now()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set local variables: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;address_table = r"UEMs with active permit etc 2013-1-11.TXT" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "address table loaded"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;address_locator = r"GIS Servers\arcgis on tasks.arcgisonline.com\Locators\TA_Address_NA_10.GeocodeServer" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "address locator loaded"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geocode_result = r"D:\Documents\Eclipse workspaces\PATS\geocode active 4D addresses\src\output shape files\UEM_Go_ON_import_noProblem_2013_01_11.shp" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "output file created, but not yet populated"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.GeocodeAddresses_geocoding(address_table, address_locator, "Street Address VISIBLE NONE;City CITY VISIBLE NONE;State State VISIBLE NONE;Zip Zip VISIBLE NONE", geocode_result, "STATIC") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;duration=time.time()-startTime&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "done! I took ",duration/60," minutes to run"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Jan 2013 23:02:04 GMT</pubDate>
    <dc:creator>ramsesmadou</dc:creator>
    <dc:date>2013-01-16T23:02:04Z</dc:date>
    <item>
      <title>finding shortest distance routes with python based on addresses in a file</title>
      <link>https://community.esri.com/t5/transportation-questions/finding-shortest-distance-routes-with-python-based/m-p/515533#M1703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i am using python to interact with ArcGIS and NetworkAnalyst to print out shortest routes of a set of addresses.&amp;nbsp; Currently passing lat and lon of a set of addresses (along with an object Id). Found a problem with such routes and ESRI snaps the lat/lon to a wrong street sometimes.&amp;nbsp; Hence would like to use a complete address instead of lat/lon of the address points (i.e., use unit, street address, town, state ).&amp;nbsp; What should be something like in the example I found in the doco on Analyst toolset, but I cannot find anything about the structure of the input file and the field names.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;someone please help!!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;olena&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 05:28:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/finding-shortest-distance-routes-with-python-based/m-p/515533#M1703</guid>
      <dc:creator>olenagavriliouk</dc:creator>
      <dc:date>2012-12-17T05:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: finding shortest distance routes with python based on addresses in a file</title>
      <link>https://community.esri.com/t5/transportation-questions/finding-shortest-distance-routes-with-python-based/m-p/515534#M1704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Olena,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Two things. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One, can you share your code for the routing task or direct me to where you found a good tutorial? I am trying to do something similar and can't figure it out quite yet. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Two, not sure if this will help but you could geocode the addresses first (i pasted the python code I use to geocode batches of address below). If there aren't too many addresses in your set you can then check out where they are on a base map and relocate those that are giving you trouble. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ramses&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Python scripts to geocode batches of addresses:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'''&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Created on Aug 14, 2012&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@author: rmadou&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This script geocodes batches of addresses&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To make this work you must add the geocoding service to ArcCatalog on your local machince. Here are instructions on how to do that:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Look in the Catalog Tree for GIS Services.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Expand that and select Add ArcGIS Server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. In the dialog, choose Use GIS services. Click Next.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. For the Server URL, type: &lt;/SPAN&gt;&lt;A href="http://tasks.arcgisonline.com/arcgis/services"&gt;http://tasks.arcgisonline.com/arcgis/services&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;5. Press ok. You should now see arcgis on tasks.arcgisonline.com in that GIS servers list.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6. Expand the connection and expand the locators folder. Select and click on the locator you want to use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7. Copy the full location path from the Location bar at the top of ArcCatalog. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you must also map your data headers to the GeocodeAddresses_geocoding headers &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for more information on the arcpy function/s used here see:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/#/Geocode_Addresses/002600000006000000/"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/#/Geocode_Addresses/002600000006000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;'''&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy,time, datetime&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#class Geocode():&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#&amp;nbsp;&amp;nbsp;&amp;nbsp; def RunGeoCoding(self):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;startTime = time.time()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "geocoding started at", datetime.datetime.now()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set local variables: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;address_table = r"UEMs with active permit etc 2013-1-11.TXT" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "address table loaded"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;address_locator = r"GIS Servers\arcgis on tasks.arcgisonline.com\Locators\TA_Address_NA_10.GeocodeServer" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "address locator loaded"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;geocode_result = r"D:\Documents\Eclipse workspaces\PATS\geocode active 4D addresses\src\output shape files\UEM_Go_ON_import_noProblem_2013_01_11.shp" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "output file created, but not yet populated"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.GeocodeAddresses_geocoding(address_table, address_locator, "Street Address VISIBLE NONE;City CITY VISIBLE NONE;State State VISIBLE NONE;Zip Zip VISIBLE NONE", geocode_result, "STATIC") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;duration=time.time()-startTime&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "done! I took ",duration/60," minutes to run"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Jan 2013 23:02:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/finding-shortest-distance-routes-with-python-based/m-p/515534#M1704</guid>
      <dc:creator>ramsesmadou</dc:creator>
      <dc:date>2013-01-16T23:02:04Z</dc:date>
    </item>
  </channel>
</rss>

