Hi I am trying to geocode addresses and make a route using arcpy and arcgis online. I successfully complete the geocode using arcpy and arcgis online. Using CSV file data and generate points data as file geodatabase into the PC. (I found the sample below) https://github.com/deelesh/batch-geocoding-python/blob/master/BatchGeocoding.py
It works fine and the accuracy is far better than address locator using census data.
Now I try to find the sample or instruction to make a route using arcgisonline routing service. I search but hard to find, I found network analyst sample like below and it works ok with census street_ND for some address, though I got some run time errors. Is there any way I can use arcgis online route service and save the result into File Geodatabase or Shape file in local computer? Thank you!
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
==== import arcpy
#Set up the environment arcpy.env.overwriteOutput = True arcpy.CheckOutExtension("network")
#Make a new route layer using travel time as impedance to determine fastest route routeLayer = arcpy.na.MakeRouteLayer(networkDataset, "StoresRoute", "TravelTime").getOutput(0)
#Get the network analysis class names from the route layer naClasses = arcpy.na.GetNAClassNames(routeLayer)
#Get the routes sublayer from the route layer routesSublayer = arcpy.mapping.ListLayers(routeLayer, naClasses["Routes"])[0]
#Copy the route as a feature class arcpy.management.CopyFeatures(routesSublayer, fastestRoute)
#Get the RouteSolverProperties object from the route layer to modify the #impedance property of the route layer. solverProps = arcpy.na.GetSolverProperties(routeLayer)
#Set the impedance property to "Meters" to determine the shortest route. solverProps.impedance = "Meters"
#Resolve the route layer arcpy.na.Solve(routeLayer)
#Copy the route as a feature class arcpy.management.CopyFeatures(routesSublayer, shortestRoute)
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: https://gist.github.com/khibma/7485243
In arcpy way sample, How to find the exact function name and parameters? Below example, the function name Viewshed_viewshedAlias is used and I think that is the one imported from http://sampleserver1.arcgisonline.com/
Is that way I can do with routing service and out put the line feature in ArcPY way? If I use ArcPy way instead of Rest way if possible, how to access the service? According to the help of ImportToolbox URL;servicename;{username};{password}