<?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: How to access arcgis online for routing service from arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-access-arcgis-online-for-routing-service/m-p/127978#M9939</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's the two help topics which should get you started. The only part I'm not sure of is the authorization. I'd need to make time to try it, but I think you can use these services with a simple token (that you must obtain). This is a very "simple" generate token function here: &lt;/SPAN&gt;&lt;A href="https://gist.github.com/khibma/7485243"&gt;https://gist.github.com/khibma/7485243&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This help page explains the input parameters to the service for the REST endpoint of the online service: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Route_service_with_asynchronous_execution/02r300000275000000/"&gt;http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Route_service_with_asynchronous_execution/02r300000275000000/&lt;/A&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This help topic has 2 sections in it: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/#/Using_a_geoprocessing_service_in_Python_scripts/00570000004w000000/"&gt;http://resources.arcgis.com/en/help/main/10.2/#/Using_a_geoprocessing_service_in_Python_scripts/00570000004w000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;The first shows how to Import a toolbox from an online source. The second shows how to use the service from its REST end point. Use whatever method makes the most sense to you in regards to using the online service.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Apr 2014 11:56:46 GMT</pubDate>
    <dc:creator>KevinHibma</dc:creator>
    <dc:date>2014-04-09T11:56:46Z</dc:date>
    <item>
      <title>How to access arcgis online for routing service from arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-arcgis-online-for-routing-service/m-p/127977#M9938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi I am trying to geocode addresses and make a route using arcpy and arcgis online.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I successfully complete the geocode using arcpy and arcgis online.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Using CSV file data and generate points data as file geodatabase into the PC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(I found the sample below)&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="https://github.com/deelesh/batch-geocoding-python/blob/master/BatchGeocoding.py"&gt;https://github.com/deelesh/batch-geocoding-python/blob/master/BatchGeocoding.py&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It works fine and the accuracy is far better than address locator using census data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I try to find the sample or instruction to make a route using arcgisonline routing service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I search but hard to find, I found network analyst sample like below and it works ok&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with census street_ND for some address, though I got some run time errors.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there any way I can use arcgis online route service and save &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;the result into File Geodatabase or Shape file in local computer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is some sample just using locat Street_ND from census but 30% of address results in the error when I geocode it using Census geocodor, so I would like to use ArcGIS route service to make a route from points layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;====&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set up the environment&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CheckOutExtension("network")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set up variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;networkDataset = "C:\EsriPress\GIST1\Network Analyst\Tutorial\SanFrancisco.gdb\Transportation\Streets_ND"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;stops = "C:\EsriPress\GIST1\Network Analyst\Tutorial\SanFrancisco.gdb\Analysis\Stores"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fastestRoute = "C:\EsriPress\GIST1\Network Analyst\Tutorial\SanFrancisco.gdb\FastestRoute"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;shortestRoute = "C:\EsriPress\GIST1\Network Analyst\Tutorial\SanFrancisco.gdb\ShortestRoute"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Make a new route layer using travel time as impedance to determine fastest route&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routeLayer = arcpy.na.MakeRouteLayer(networkDataset, "StoresRoute", "TravelTime").getOutput(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Get the network analysis class names from the route layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;naClasses = arcpy.na.GetNAClassNames(routeLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Get the routes sublayer from the route layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routesSublayer = arcpy.mapping.ListLayers(routeLayer, naClasses["Routes"])[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Load stops&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.na.AddLocations(routeLayer, naClasses["Stops"], stops)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Solve the route layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.na.Solve(routeLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Copy the route as a feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.management.CopyFeatures(routesSublayer, fastestRoute)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Get the RouteSolverProperties object from the route layer to modify the&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#impedance property of the route layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;solverProps = arcpy.na.GetSolverProperties(routeLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set the impedance property to "Meters" to determine the shortest route.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;solverProps.impedance = "Meters"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Resolve the route layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.na.Solve(routeLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Copy the route as a feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.management.CopyFeatures(routesSublayer, shortestRoute)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Completed")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 22:17:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-arcgis-online-for-routing-service/m-p/127977#M9938</guid>
      <dc:creator>TakeoShibata</dc:creator>
      <dc:date>2014-04-08T22:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to access arcgis online for routing service from arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-arcgis-online-for-routing-service/m-p/127978#M9939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's the two help topics which should get you started. The only part I'm not sure of is the authorization. I'd need to make time to try it, but I think you can use these services with a simple token (that you must obtain). This is a very "simple" generate token function here: &lt;/SPAN&gt;&lt;A href="https://gist.github.com/khibma/7485243"&gt;https://gist.github.com/khibma/7485243&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This help page explains the input parameters to the service for the REST endpoint of the online service: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Route_service_with_asynchronous_execution/02r300000275000000/"&gt;http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Route_service_with_asynchronous_execution/02r300000275000000/&lt;/A&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This help topic has 2 sections in it: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/#/Using_a_geoprocessing_service_in_Python_scripts/00570000004w000000/"&gt;http://resources.arcgis.com/en/help/main/10.2/#/Using_a_geoprocessing_service_in_Python_scripts/00570000004w000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;The first shows how to Import a toolbox from an online source. The second shows how to use the service from its REST end point. Use whatever method makes the most sense to you in regards to using the online service.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 11:56:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-arcgis-online-for-routing-service/m-p/127978#M9939</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2014-04-09T11:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to access arcgis online for routing service from arcpy</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-arcgis-online-for-routing-service/m-p/127979#M9940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Kevin&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am now looking at &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/#/Using_a_geoprocessing_service_in_Python_scripts/00570000004w000000/"&gt;http://resources.arcgis.com/en/help/main/10.2/#/Using_a_geoprocessing_service_in_Python_scripts/00570000004w000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;and the ImportToolbox in arcpy wat seems to be the resonable way if I understand correct.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(REST way, I send and I have to decode JSON reply strings and create feature from it manually, right?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In arcpy way sample,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How to find the exact function name and parameters?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Below example, the function name&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Viewshed_viewshedAlias&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is used and I think that is the one imported from &lt;/SPAN&gt;&lt;A href="http://sampleserver1.arcgisonline.com/"&gt;http://sampleserver1.arcgisonline.com/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is that way I can do with routing service and out put the line feature in ArcPY way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I use ArcPy way instead of Rest way if possible, how to access the service?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the help of ImportToolbox&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;URL;servicename;{username};{password}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;=====&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import time&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;arcpy.ImportToolbox("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://sampleserver1.arcgisonline.com/ArcGIS/services;Elevation/ESRI_Elevation_World" rel="nofollow" target="_blank"&gt;http://sampleserver1.arcgisonline.com/ArcGIS/services;Elevation/ESRI_Elevation_World&lt;/A&gt;&lt;SPAN&gt;", "viewshedAlias")&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result = arcpy.Viewshed_viewshedAlias(r'c:\data\inputPoint.shp', "10000 Kilometers")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while result.status &amp;lt; 4:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print result.status&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; time.sleep(0.2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print "Execution Finished"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;result.getMessages()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CopyFeatures_management(result.getOutput(0), 'localResult.shp')&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 20:26:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-arcgis-online-for-routing-service/m-p/127979#M9940</guid>
      <dc:creator>TakeoShibata</dc:creator>
      <dc:date>2014-04-10T20:26:17Z</dc:date>
    </item>
  </channel>
</rss>

