Select to view content in your preferred language

Optimum Routing

710
5
03-26-2024 09:51 AM
QassimNasir
Emerging Contributor

Dears

I am seeking your assistance in directing me to a tutorial with examples if about how to call and use optimum routing for single or multiple deliveries using Python calls.

Best Regards

0 Kudos
5 Replies
John-Foster
Esri Contributor

@QassimNasirReview the material on this page https://developers.arcgis.com/documentation/mapping-apis-and-services/routing/optimized-routing/ and select ArcGIS API for Python in the code switchers to see the Python code.

--jf
0 Kudos
QassimNasir
Emerging Contributor

Many thanks

Unforuntely, I find only those

ArcGIS Maps SDK for Kotlin
ArcGIS Maps SDK for Swift
ArcGIS Maps SDK for .NET
ArcGIS Maps SDK for Qt

I could not find Python in there.

 

0 Kudos
QassimNasir
Emerging Contributor

Thank you so much. That code can be used for Enterprise as well?

# Connect to the routing service and call it
api_key = "YOUR_API_KEY"
portal = arcgis.GIS("https://www.arcgis.com", api_key=api_key)
route = arcgis.network.RouteLayer(
portal.properties.helperServices.route.url, gis=portal
)
result = route.solve(
stops=stops,
start_time="now",
find_best_sequence=True,
)
print_result(result)

if __name__ == "__main__":
main()

 

0 Kudos
John-Foster
Esri Contributor

Hi @QassimNasir , the code I referred you to cannot be used with ArcGIS Enterprise because API keys are not supported. In that case you should use username and password when creating portal.

 

portal = arcgis.GIS("https://www.arcgis.com", username="<USERNAME>", password="<PASSWORD>")

 

--jf
0 Kudos