How to convert or export ArcGIS REST API Route service result to desktop mapping format?

1151
4
12-10-2018 03:22 AM
ChristopherZapp
New Contributor II

I am successful in getting results from ArcGIS REST API Route service using simple parameters (two points; x&y) but the resulting json is not in a format easily readable in desktop format. When I try to convert to shp or other format (in ArcMap or online tool), I receive parsing error as the resulting json is not similar to other json outputs I've encountered. I'm curious if anyone has had success converting or exporting Route service results into desktop mapping format. Below documentation I have been following (apologies in advance- I am not a developer/coder):

Get a route and directions | ArcGIS for Developers 

Route service with synchronous execution—ArcGIS REST API: Directions and Routing Services | ArcGIS f... 

Route service with asynchronous execution—ArcGIS REST API: Directions and Routing Services | ArcGIS ... 

Moreover, I am interested if anyone has had success using a feature service URL as parameter stops for this request. Please provide useful steps or hints as ESRI documentation is very simple (i.e. do field names of feature service need to be named specifically, etc.).

Thanks!

Tags (1)
0 Kudos
4 Replies
KonstantinKutsner
New Contributor

The solution depends on the ultimate goal... but let's say you can use "Route service with asynchronous execution", Then, there is a parameter "save_route_data" (Route service with asynchronous execution—ArcGIS REST API: Directions and Routing Services | ArcGIS ...). The generated zip file will contain File Geodatabase that will contain all route data.

But let's say consuming File Geodatabase is not an option, then route result returned by server contains multiple record sets, such as route, stops, barriers, directions. So you need to convert every individual record set separately. Although, directions record set is not a regular record set and the conversion will fail so it will require some extra work to make conversion working.

ChristopherZapp
New Contributor II

Hi Konstantin,

Thanks for this feedback- very helpful. I have explored this option in ArcGIS Online, which allows multiple route connections and more user-friendly than the API REST service: 

Connect Origins to Destinations—ArcGIS Online Help | ArcGIS 

Thanks!

0 Kudos
ChristopherZapp
New Contributor II

Hi Konstanin,

I actually ran into a problem using Connect Origins to Destinations in ArcGIS Online (Performing "Connect Origins to Destinations for many to many" analysis in GIS online? - origins and destinations must be equal). So I tried the asynchronous routing service and finally got it to work with ability to request multiple routes at a time. I explain below process for anyone needing reference. Thanks again!

ESRI documentation: https://developers.arcgis.com/rest/network/api-reference/route-asynchronous-service.htm#

Prepare data in csv with following columns:

x = longitude of stop (WGS 84 decimal)

y = latitude of stop (WGS 84 decimal)

Name = name of stop (origin -> stop -> destination)

RouteName = unique ID grouping each route together

Convert csv to json with http://www.convertcsv.com/csv-to-json.htm using template:

--Top

{lb}"features": [

 

--Repeating Section

{lb}

"geometry": {lb}

"x": {f1},

"y": {f2}

{rb},

 "attributes": {lb}

"Name": "{f3}",

"RouteName": {f4}

{rb}

{rb}

 

--Bottom

]{rb}

 

Use Postman to complete request using parameters in ESRI documentation

Thanks again!

AndyBlackman2
New Contributor II

Hi Konstantin Kutsner,

I am experimenting using the API to perform multiple vehicle routing and can view the results in Postman, but I would like to display them on a map. I've set the save_route_data parameter to true, but I can't see where the ZIP file is created to download and query. Please can you help?

Thanks

Andy

0 Kudos