1. Choose a type of routing
The first step is to select the correct service endpoint and the operation you need to use. Each routing operation has a direct and job request endpoint. Use a direct request for shorter transactions with less than 150 stops. For longer transactions, use a job request. To learn more about direct and job requests, go to the topic page for each operation below.
Direct request
1
https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?<parameters>
Job request
1
https://logistics.arcgis.com/arcgis/rest/services/World/Route/GPServer/FindRoutes/submitJob?<parameters>
Direct request
1
https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve?findBestSequence=true&<parameters>
Job request
1
https://logistics.arcgis.com/arcgis/rest/services/World/Route/GPServer/FindRoutes/submitJob?<parameters>
Direct request
1
https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblemSync/GPServer/EditVehicleRoutingProblem/execute?<parameters>
Job request
1
https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob?<parameters>
Direct request
1
https://route-api.arcgis.com/arcgis/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World/solveClosestFacility?<parameters>
Job request
1
https://logistics.arcgis.com/arcgis/rest/services/World/ClosestFacility/GPServer/FindClosestFacilities/submitJob?<parameters>
Direct request
1
https://route-api.arcgis.com/arcgis/rest/services/World/ServiceAreas/NAServer/ServiceArea_World/solveServiceArea?<parameters>
Job request
1
https://logistics.arcgis.com/arcgis/rest/services/World/ServiceAreas/GPServer/GenerateServiceAreas/submitJob?<parameters>
Direct request
1
https://route-api.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World/solveODCostMatrix?<parameters>
Job request
1
https://logistics.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/GPServer/GenerateOriginDestinationCostMatrix/submitJob?<parameters>
Location allocation only supports job requests.
1
https://logistics.arcgis.com/arcgis/rest/services/World/LocationAllocation/GPServer/SolveLocationAllocation/submitJob?<parameters>
Operation | Use case |
---|---|
Simple routing | Find the best path from an origin to a destination for a single individual or vehicle. |
Optimized routing | Find the best path to travel for a single vehicle when you need to stop at multiple destinations. |
Fleet routing | Determine the most effective routes for a set of vehicles that need to visit a set of locations, while also minimizing transportation costs. |
Closest facility routing | Find one or more nearby facilities from incidents based on travel time or travel distance. |
Service areas | Create an isochrone that represents the distance that can be reached when driving or walking on a street network. |
Travel cost matrix | Create a table or a matrix containing the cost, such as the travel time or travel distance, from multiple origins to multiple destinations |
Location-allocation | Allocate demand to existing locations and find one or more new locations to maximize the number of customers that walk to a location. |
2. Define input parameters
The next step is to provide the required input parameters for the operation. Most operations require stops
, facilities
, or orders
to define the locations to visit to along a route. Depending on the operation, other parameters may be required. The tables below show the typical input parameters for direct requests.
Name | Description | Examples |
---|---|---|
stops | The two or more locations that need to be visited in the route. | stops=-117,34; -117.5,34.5 |
travel | The mode of transportation such as driving a car or a truck or walking. | travel JSON Object |
start | The time at which travel begins from the input stops. You can also specify a value of now , to set the depart time to the current time. | start |
return | Generate driving directions for each route. | return |
directions | The language to be used when generating driving directions. | directions |
Name | Description | Examples |
---|---|---|
stops | The two or more locations that need to be visited in the route. | stops=-117,34; -117.5,34.5 |
travel | The mode of transportation such as driving a car or a truck or walking. | travel JSON Object |
start | The time at which travel begins from the input stops. You can also specify a value of now , to set the depart time to the current time. | start |
return | Generate driving directions for each route. | return |
directions | The language to be used when generating driving directions. | directions |
Name | Description |
---|---|
orders |
A list of locations to visit with attributes such as the order name or the time required to complete the delivery at each order. |
depots |
The start and the return location for the vehicles. |
routes |
The characteristics and constraints for each vehicle. For example, the start and the return depot name, the maximum number of orders a vehicle is allowed to visit, and the total time the vehicle is allowed to operate. |
travel |
The mode of transportation such as driving a car or a truck. |
default |
The date on which all of your routes start. |
populate |
Generate driving directions for the routes. |
Name | Description | Examples |
---|---|---|
facilities | Set of locations from which to choose the nearest locations. | facilities=-117.190774,34.057301;-117.199781,34.06047 |
incidents | One or more locations from which to start searching for the nearby locations. | incidents=-117.195696,34.056503 |
travel | The mode of transportation such as driving a car or a truck or walking. | travel JSON Object |
default | The number of closest facilities to find per incident. | default |
default | The travel time or travel distance value at which to stop searching for facilities for a given incident. | default |
travel | Whether you want to search for the closest facility as measured from the incident to the facility or from the facility to the incident. | travel |
Name | Description | Examples |
---|---|---|
facilities | One or more locations around which service areas are generated. | facilities=-117,34 |
default | The size and number of service areas to generate for each facility. | default |
travel | The mode of transportation such as driving a car or a truck or walking. | travel JSON Object |
travel | The direction of travel (away from facility or towards facility) that should be used when generating service areas. | travel |
time | The time to depart from or arrive at facilities. You can also specify a value of now , to set the depart or arrive time to current time. | time |
Name | Description | Examples |
---|---|---|
origins | Starting locations from which to travel to the destinations. | origins=-118.245843,34.057794;-117.16274,32.719178 |
destinations | Ending locations to travel to from the origins. | destinations=-117.182676,34.055909;-118.144184,34.147832 |
travel | The mode of transportation such as driving a car or a truck or walking. | travel JSON Object |
default | The number of destinations to find per origin. A null value or no value for this parameter results in a search for all destinations from every origin. | default default |
default | The travel time or travel distance value at which to stop searching for destinations from a given origin. The default value is null which means to search until all destinations are found for every origin. The units are time or distance based depending on your travel mode. | default |
Name | Description | Examples |
---|---|---|
facilities | One or more locations that serve as facilities. | facilities={"features" |
demand | One or more locations that represent demand for the services offered at the facilities. | demand |
travel | The mode of transportation such as driving a car or a truck or walking. | travel JSON Object |
problem | The objective of the location-allocation analysis | problem |
number | Number of facilities the service should choose | number |
3. Make a request
The final step is to make a request to the routing service using an ArcGIS Maps SDK, scripting API, or open source library. In general, you:
- Reference the service or import the relevant packages or modules.
- Set the parameters for the operation.
- Set the access token.
APIs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
function getRoute() {
const routeUrl = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
const routeParams = new RouteParameters({
stops: new FeatureSet({
features: view.graphics.toArray()
}),
returnDirections: true,
directionsLanguage: "es"
});
route.solve(routeUrl, routeParams)
.then((data)=> {
if (data.routeResults.length > 0) {
showRoute(data.routeResults[0].route);
showDirections(data.routeResults[0].directions.features);
}
})
.catch((error)=>{
console.log(error);
})
}
REST API
1
2
3
4
5
6
7
curl https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve? \
-d "f=json"
-d "token=<ACCESS_TOKEN>"
-d "stops=-122.68782,45.51238;-122.690176,45.522054;-122.614995,45.526201"
-d "startTime=now"
-d "returnDirections=true"
-d "directionsLanguage=es"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{
"routes": {
"fieldAliases": {
// one or more field aliases
},
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"features": [
{
"attributes": {
"Name": "Location 1 - Location 3",
"Total_TravelTime": 14.758,
"Total_Miles": 5.491,
"Total_Kilometers": 8.837
// more field values
},
"geometry": {
"paths": [
[
[
-122.68838,
45.51262
]
// additional points that make up the path geometry between location 1 and location 2
],
[
[
-122.69019,
45.52206
]
// additional points that make up the path geometry between location 2 and location 3
]
]
}
}
]
},
"directions": [
{
"routeId": 1,
"routeName": "Location 1 - Location 3",
"summary": {
"totalLength": 5.491,
"totalTime": 14.758,
"totalDriveTime": 14.758,
"envelope": {
"xmin": -122.69257,
"ymin": 45.51262,
"xmax": -122.61497,
"ymax": 45.53422,
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
}
}
},
"features": [
{
"attributes": {
"length": 0,
"time": 0,
"text": "Salga desde Location 1",
"ETA": 1607894119000,
"arriveTimeUTC": 1607922919000,
"maneuverType": "esriDMTDepart"
},
"compressedGeometry": "+gm5a9-1vvvvvh+nnn9tf+0+0",
"strings": [
{
"string": "9:15 PM",
"stringType": "esriDSTEstimatedArrivalTime"
},
{
"string": "Location 1",
"stringType": "esriDSTStreetName"
}
]
},
{
"attributes": {
"length": 0.024,
"time": 0.054,
"text": "Vaya hacia el noreste",
"ETA": 1607894119000,
"arriveTimeUTC": 1607922919000,
"maneuverType": "esriDMTStraight"
},
"compressedGeometry": "+gm5a9-1vvvvvh+nnn9tf+8a+j6+1h7+59i",
"strings": [
{
"string": "9:15 PM",
"stringType": "esriDSTEstimatedArrivalTime"
}
]
}
// more direction features
]
}
]
}
APIs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
const findRoutes = () => {
stopsFL.queryFeatures().then(graphics => {
const optRouteParams = new EsriRouteParams({
apiKey: appConfig._apiKey,
findBestSequence: true,
returnStops: true,
stops: graphics,
returnDirections: true,
})
EsriRoute.solve(appConfig.routeUrl, optRouteParams).then(
routeSolveDidComplete
)
})
}
REST API
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
curl https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World/solve? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d 'stops={
"spatialReference": {
"wkid": 4326
},
"features": [
{
"attributes": {
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
{
"messages": [
{
"type": 50,
"description": "Input field [Address] was not mapped to a field in the network analysis class \"Stops\"."
},
{
"type": 50,
"description": "Input field [InspectionRequired] was not mapped to a field in the network analysis class \"Stops\"."
},
{
"type": 50,
"description": "Network elements with avoid-restrictions are traversed in the output (restriction attribute names: \"Through Traffic Prohibited\")."
}
],
"checksum": "nul8AMDrfADR7nwAIgJ9AH7wfAA7A30ANwN9AOcFfQCmCn0Aigl9AA..",
"requestID": "86acd541-f097-4802-90de-6fe8e42a515f",
"routes": {
"fieldAliases": {
"ObjectID": "ObjectID",
"Name": "Name",
"FirstStopID": "FirstStopID",
"LastStopID": "LastStopID",
"StopCount": "StopCount",
"Total_TravelTime": "Total_TravelTime",
"Total_Miles": "Total_Miles",
"Total_Kilometers": "Total_Kilometers",
"Shape_Length": "Shape_Length"
},
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"features": [
{
"attributes": {
"ObjectID": 1,
"Name": "The Fish Market - Turf Supper Club",
"FirstStopID": 1,
"LastStopID": 10,
"StopCount": 10,
"Total_TravelTime": 31.619262792389609,
"Total_Miles": 8.1204472588724705,
"Total_Kilometers": 13.068628415906755,
"Shape_Length": 0.1278887744845883
},
"geometry": {
"paths": [
[
[-117.17534338099995, 32.712356905000036],
[-117.17508999999995, 32.712190000000078],
[-117.17446999999999, 32.71216000000004],
[-117.17409999999995, 32.712350000000072],
[-117.17383999999998, 32.712480000000028],
[-117.17344999999995, 32.712510000000066],
[-117.17338999999998, 32.71252000000004],
[-117.17327999999998, 32.712540000000047],
[-117.17308999999995, 32.712570000000028],
[-117.17297999999994, 32.712570000000028],
[-117.17297999999994, 32.712530000000072],
[-117.17293999999998, 32.712200000000053],
[-117.17262999999997, 32.711680000000058],
[-117.17254999999994, 32.711610000000064]
// more paths
]
]
}
}
]
}
}
APIs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
const geoprocessorUrl = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblemSync/GPServer/EditVehicleRoutingProblem"
const params = {
orders, // Feature Set
depots, // Feature Set
routes, // Feature Set
populate_directions: true // "Generate driving directions for the routes"
};
const { results } = await geoprocessor.execute(geoprocessorUrl, params);
const outStops = results[1].value.features; // Graphics[]
const outRoutes = results[2].value.features; // Graphics[]
showStops(outStops);
showRoutes(outRoutes);
}
REST API
1
2
3
4
5
6
7
curl https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblemSync/GPServer/EditVehicleRoutingProblem/execute? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "orders={'type':'features','features':[{'attributes':{'Name':'Father\'s Office','ServiceTime':10},'geometry':{'x':-118.498406,'y':34.029445}},{'attributes':{'Name':'R+D Kitchen','ServiceTime':10},'geometry':{'x':-118.495788,'y':34.032339}},{'attributes':{'Name':'Pono Burger','ServiceTime':10},'geometry':{'x':-118.489469,'y':34.019000}},{'attributes':{'Name':'Il Ristorante di Giorgio Baldi','ServiceTime':10},'geometry':{'x':-118.518787,'y':34.028508}},{'attributes':{'Name':'Milo + Olive','ServiceTime':10},'geometry':{'x':-118.476026,'y':34.037572}},{'attributes':{'Name':'Dialogue','ServiceTime':10},'geometry':{'x':-118.495814,'y':34.017042}}]}" \
-d "depots={'type':'features','features':[{'attributes':{'Name':'Bay Cities Kitchens and Appliances'},'geometry':{'x':-118.469630,'y':34.037555}}]}" \
-d "routes={'features':[{'attributes':{'Name':'Route 1','Description':'vehicle 1','StartDepotName':'Bay Cities Kitchens and Appliances','EndDepotName':'Bay Cities Kitchens and Appliances','Capacities':'4','MaxOrderCount':3,'MaxTotalTime':60,}},{'attributes':{'Name':'Route 2','Description':'vehicle 2','StartDepotName':'Bay Cities Kitchens and Appliances','EndDepotName':'Bay Cities Kitchens and Appliances','Capacities':'4','MaxOrderCount':3,'MaxTotalTime':60,}}]}" \
-d "populate_directions=true"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
{
"results": [
{
"paramName": "out_stops",
"value": {
"fields": [
// One or more field definitions
],
"features": [
{
"attributes": {
"Name": "Father's Office",
"RouteName": "Route 1"
// more field values
}
},
// additional stops assigned to Route 1
{
"attributes": {
"Name": "Pono Burger",
"RouteName": "Route 2"
// more field values
}
}
// additional stops assigned to Route 2
],
"exceededTransferLimit": false
}
},
{
"paramName": "out_routes",
"value": {
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"fields": [
// One or more field definitions
],
"features": [
{
"attributes": {
"Name": "Route 1",
"OrderCount": 3,
"TotalTime": 44.35174229927361,
"TotalOrderServiceTime": 30,
"TotalTravelTime": 14.35174229927361,
"TotalDistance": 4.7165690223626644
// more field values
},
"geometry": {
"paths": [
[
[
-118.46985210799994,
34.037297225000032
]
// additional points that make up the path geometry
],
[
[
-118.49848681399999,
34.029544464000026
]
// additional points that make up the path geometry
]
// additional path that make up the route
]
}
},
{
"attributes": {
"Name": "Route 2",
"OrderCount": 3,
"TotalTime": 53.712840937077999,
"TotalOrderServiceTime": 30,
"TotalTravelTime": 23.712840937077999,
"TotalDistance": 8.9522377804877333
// more field values
},
"geometry": {
"paths": [
// one or more paths that make up the route
]
}
}
],
"exceededTransferLimit": false
}
},
{
"paramName": "out_directions",
"value": {
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"fields": [
// One or more field definitions
],
"features": [
{
"attributes": {
"RouteName": "Route 1",
"ArriveTime": 1606291199999,
"Text": "Start at Bay Cities Kitchens & Appliances",
"ElapsedTime": 0,
"DriveDistance": 0
// more field values
}
},
{
"attributes": {
"RouteName": "Route 1",
"ArriveTime": 1606291199999,
"Text": "Go northwest on Berkeley St toward Arizona Ave",
"ElapsedTime": 1.020147442817688,
"DriveDistance": 0.23870387673377991
// more field values
},
"geometry": {
"paths": [
// one or more path that make up the direction geometry
]
}
},
// additional driving directions for Route 1
{
"attributes": {
"RouteName": "Route 1",
"ArriveTime": 1606293904131,
"Text": "Finish at Bay Cities Kitchens & Appliances, on the left",
"ElapsedTime": 0,
"DriveDistance": 0
// more field values
}
}
// additional driving directions for Route 2
],
"exceededTransferLimit": false
}
}
// additional output parameters
],
"messages": [
{
"type": "esriJobMessageTypeWarning",
"description": "Network elements with avoid-restrictions are traversed in the output (restriction attribute names: \"Through Traffic Prohibited\")."
}
]
}
APIs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
function findClosestFacility(startFeature, facilityFeatures) {
const params = new ClosestFacilityParameters({
incidents: new FeatureSet({
features: [startFeature],
}),
facilities: new FeatureSet({
features: facilityFeatures.toArray(),
}),
returnRoutes: true,
returnFacilities: true,
defaultTargetFacilityCount: 3,
});
const url = "https://route-api.arcgis.com/arcgis/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World";
closestFacility.solve(url, params).then(
(results) => {
showRoutes(results.routes);
},
(error) => {
console.log(error.details);
}
);
}
REST API
1
2
3
4
5
6
7
8
curl https://route-api.arcgis.com/arcgis/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World/solveClosestFacility? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "facilities={'spatialReference':{'latestWkid':3857,'wkid':102100},'features':[{'geometry':{'x':-13656100.72194608,'y':5703897.952531632},'attributes':{'Name':'Downtown Grocery, 310 SW 4th Ave, Portland, OR, 97204, USA'}},{'geometry':{'x':-13657081.446659965,'y':5704279.273731899},'attributes':{'Name':'Whole Foods Market, 1210 NW Couch St, Portland, OR, 97209, USA'}},{'geometry':{'x':-13654900.697835328,'y':5704360.306582605},'attributes':{'Name':'Pacific Coast Fruit Company, 201 NE 2nd Ave, Portland, Oregon, 97232'}},{'geometry':{'x':-13654793.831124166,'y':5703907.485363393},'attributes':{'Name':'Nicky USA, 223 SE 3rd Ave, Portland, OR, 97214, USA'}},{'geometry':{'x':-13654829.453361219,'y':5703721.596977669},'attributes':{'Name':'Alexis Foods, 215 SE Stark St, Portland, OR, 97214, USA'}},{'geometry':{'x':-13654680.285243554,'y':5703712.064344136},'attributes':{'Name':'Sheridan Fruit Company, 408 SE Martin Luther King, Portland, OR, 97214, USA'}},{'geometry':{'x':-13654723.699844966,'y':5703513.470124055},'attributes':{'Name':'Graziano Food Services, 302 SE Washington St, Portland, OR, 97214, USA'}},{'geometry':{'x':-13654781.585980177,'y':5703484.872919755},'attributes':{'Name':'Rinella Produce, 231 SE Alder St, Portland, OR, 97214, USA'}}]}" \
-d "incidents={'spatialReference':{'latestWkid':3857,'wkid':102100},'features':[{'geometry':{'x':-13656119.041436872,'y':5703857.952531632},'attributes':{'Name':'322 SW 4th Ave, Portland, OR, 97204, USA'}}]}" \
-d "defaultTargetFacilityCount=3" \
-d "returnFacilities=true" \
-d "returnCFRoutes=true"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
{
"messages": [],
"routes": {
"fieldAliases": {
// one or more field aliases
},
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"features": [
{
"attributes": {
"FacilityID": 1,
"FacilityRank": 1,
"Name": "322 SW 4th Ave, Portland, OR, 97204, USA - Downtown Grocery, 310 SW 4th Ave, Portland, OR, 97204, USA",
"Total_TravelTime": 1.5196098637007482,
"Total_Miles": 0.21780962607880719
// more field values
APIs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
async function findServiceArea(locationFeature) {
if (!travelMode) {
const networkDescription = await networkService.fetchServiceDescription(url);
travelMode = networkDescription.supportedTravelModes.find(
(travelMode) => travelMode.name === "Walking Distance"
);
}
const serviceAreaParameters = new ServiceAreaParameters({
facilities: new FeatureSet({
features: [locationFeature]
}),
defaultBreaks: [2.5], // km
travelMode,
travelDirection: "to-facility",
outSpatialReference: view.spatialReference,
trimOuterPolygon: true
});
const { serviceAreaPolygons } = await serviceArea.solve(url, serviceAreaParameters);
showServiceAreas(serviceAreaPolygons);
}
REST API
1
2
3
4
5
6
7
curl https://route-api.arcgis.com/arcgis/rest/services/World/ServiceAreas/NAServer/ServiceArea_World/solveServiceArea? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "facilities=-117.133163,34.022445" \
-d "defaultBreaks=2.5" \
-d "travelDirection=esriNATravelDirectionToFacility" \
-d "travelMode={'attributeParameterValues':[{'attributeName':'Avoid Private Roads','parameterName':'Restriction Usage','value':'AVOID_MEDIUM'},{'attributeName':'Walking','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Preferred for Pedestrians','parameterName':'Restriction Usage','value':'PREFER_LOW'},{'attributeName':'WalkTime','parameterName':'Walking Speed (km/h)','value':5},{'attributeName':'Avoid Roads Unsuitable for Pedestrians','parameterName':'Restriction Usage','value':'AVOID_HIGH'}],'description':'Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel distance.','distanceAttributeName':'Kilometers','id':'yFuMFwIYblqKEefX','impedanceAttributeName':'Kilometers','name':'Walking Distance','restrictionAttributeNames':['Avoid Private Roads','Avoid Roads Unsuitable for Pedestrians','Preferred for Pedestrians','Walking'],'simplificationTolerance':2,'simplificationToleranceUnits':'esriMeters','timeAttributeName':'WalkTime','type':'WALK','useHierarchy':false,'uturnAtJunctions':'esriNFSBAllowBacktrack'}"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
"messages": [],
"saPolygons": {
"fieldAliases": {
"Name": "Name"
// more field aliases
},
"geometryType": "esriGeometryPolygon",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"features": [
{
"attributes": {
"Name": "Location 1 : 0 - 2.5",
"FromBreak": 0,
"ToBreak": 2.5
// more field values
},
"geometry": {
"rings": [
[
[
-117.13887868499995,
34.04079974800004
],
[
-117.13820495099998,
34.040350593000028
]
// additional points that make up the ring for the polygon
]
]
}
}
]
}
}
APIs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Connect to the origin destination cost matrix service and call it
api_key = "YOUR_ACCESS_TOKEN"
portal = arcgis.GIS("https://www.arcgis.com", api_key=api_key)
od_cost_matrix = arcgis.network.ODCostMatrixLayer(portal.properties.helperServices.odCostMatrix.url,
gis=portal)
result = od_cost_matrix.solve_od_cost_matrix(origins=cities,
destinations=cities,
)
print_result(result)
REST API
1
2
3
4
5
curl https://route-api.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World/solveODCostMatrix? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "origins={'spatialReference':{'wkid':4326},'features':[{'geometry':{'x':153.03660,'y':-27.486320},'attributes':{'ObjectID':101}},{'geometry':{'x':144.983120,'y':-37.817870},'attributes':{'ObjectID':102}},{'geometry':{'x':151.223490,'y':-33.891220},'attributes':{'ObjectID':103}},{'geometry':{'x':149.133490,'y':-35.316850},'attributes':{'ObjectID':104}},{'geometry':{'x':138.596810,'y':-34.917470},'attributes':{'ObjectID':105}}]}" \
-d "destinations={'spatialReference':{'wkid':4326},'features':[{'geometry':{'x':153.03660,'y':-27.486320},'attributes':{'ObjectID':101}},{'geometry':{'x':144.983120,'y':-37.817870},'attributes':{'ObjectID':102}},{'geometry':{'x':151.223490,'y':-33.891220},'attributes':{'ObjectID':103}},{'geometry':{'x':149.133490,'y':-35.316850},'attributes':{'ObjectID':104}},{'geometry':{'x':138.596810,'y':-34.917470},'attributes':{'ObjectID':105}}]}"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
{
"messages": [],
"odCostMatrix": {
"costAttributeNames": [
"TravelTime",
"Miles",
"Kilometers"
],
"101": {
"101": [
0,
0,
0
],
"102": [
1092.7348608174257,
1046.4209599692097,
1684.0512934006936
],
"103": [
APIs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Connect to the location-allocation service
api_key = "YOUR_ACCESS_TOKEN"
arcgis.GIS("https://www.arcgis.com", api_key=api_key)
# Get the walking time travel mode defined for the portal. Fail if the travel mode is not found.
walking_time_travel_mode = ""
for feature in arcgis.network.analysis.get_travel_modes().supported_travel_modes.features:
attributes = feature.attributes
if attributes["AltName"] == "Walking Time":
walking_time_travel_mode = attributes["TravelMode"]
break
assert walking_time_travel_mode, "Walking Time travel mode not found"
# Call the location-allocation service
result = arcgis.network.analysis.solve_location_allocation(facilities=facilities,
demand_points=demand_points,
travel_mode=walking_time_travel_mode,
problem_type="Maximize Attendance",
number_of_facilities_to_find=2,
travel_direction="Demand to Facility",
)
print_result(result)
REST API
1
2
3
4
5
6
7
8
9
curl https://logistics.arcgis.com/arcgis/rest/services/World/LocationAllocation/GPServer/SolveLocationAllocation/submitJob? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>" \
-d "facilities={'features':[{'attributes':{'Name':'Existing Location','FacilityType':1},'geometry':{'x':-122.333906,'y':47.609152}},{'attributes':{'Name':'Candidate 1','FacilityType':0},'geometry':{'x':-122.333585,'y':47.604501}},{'attributes':{'Name':'Candidate 2','FacilityType':0},'geometry':{'x':-122.334550,'y':47.605557}},{'attributes':{'Name':'Candidate 3','FacilityType':0},'geometry':{'x':-122.337753,'y':47.609442}},{'attributes':{'Name':'Candidate 4','FacilityType':0},'geometry':{'x':-122.335319,'y':47.607317}}]}" \
-d "demand_points={'features':[{'attributes':{'Name':'Colman Building','Weight':1573},'geometry':{'x':-122.335583,'y':47.603495}},{'attributes':{'Name':'Norton Parking Garage','Weight':1262},'geometry':{'x':-122.33482,'y':47.603745}},{'attributes':{'Name':'DocuSign Tower','Weight':2385},'geometry':{'x':-122.334151,'y':47.605060}},{'attributes':{'Name':'Fourth and Madison Building','Weight':1096},'geometry':{'x':-122.333227,'y':47.605493}},{'attributes':{'Name':'Safeco Plaza','Weight':3618},'geometry':{'x':-122.333899,'y':47.606190}},{'attributes':{'Name':'1201 Third Avenue','Weight':1782},'geometry':{'x':-122.336163,'y':47.607204}},{'attributes':{'Name':'Puget Sound Plaza','Weight':2165},'geometry':{'x':-122.335796,'y':47.608602}},{'attributes':{'Name':'Rainier Square','Weight':1316},'geometry':{'x':-122.334881,'y':47.609021}},{'attributes':{'Name':'Century Square','Weight':1974},'geometry':{'x':-122.337503,'y':47.610273}},{'attributes':{'Name':'Miken Building','Weight':3920},'geometry':{'x':-122.336516,'y':47.609510}},{'attributes':{'Name':'Westlake Park','Weight':2467},'geometry':{'x':-122.336353,'y':47.6110466}},{'attributes':{'Name':'U.S. Bank Centre','Weight':3997},'geometry':{'x':-122.334571,'y':47.610492}},{'attributes':{'Name':'Westlake Center','Weight':2440},'geometry':{'x':-122.337406,'y':47.611980}},{'attributes':{'Name':'Nordstrom Flagship Store','Weight':2438},'geometry':{'x':-122.336295,'y':47.6123047}},{'attributes':{'Name':'Columbia Center','Weight':5400},'geometry':{'x':-122.330746,'y':47.604502}},{'attributes':{'Name':'800 Fifth Avenue','Weight':3697},'geometry':{'x':-122.330228,'y':47.605698}},{'attributes':{'Name':'Seattle Municipal Tower','Weight':2025},'geometry':{'x':-122.329605,'y':47.605143}},{'attributes':{'Name':'Washington State Convention Center','Weight':1076},'geometry':{'x':-122.331520,'y':47.611664}}]}" \
-d "travel_mode={'attributeParameterValues':[{'attributeName':'Avoid Private Roads','parameterName':'Restriction Usage','value':'AVOID_MEDIUM'},{'attributeName':'Walking','parameterName':'Restriction Usage','value':'PROHIBITED'},{'attributeName':'Preferred for Pedestrians','parameterName':'Restriction Usage','value':'PREFER_LOW'},{'attributeName':'WalkTime','parameterName':'Walking Speed (km/h)','value':5},{'attributeName':'Avoid Roads Unsuitable for Pedestrians','parameterName':'Restriction Usage','value':'AVOID_HIGH'}],'description':'Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.','distanceAttributeName':'Kilometers','id':'caFAgoThrvUpkFBW','impedanceAttributeName':'WalkTime','name':'Walking Time','restrictionAttributeNames':['Avoid Private Roads','Avoid Roads Unsuitable for Pedestrians','Preferred for Pedestrians','Walking'],'simplificationTolerance':2,'simplificationToleranceUnits':'esriMeters','timeAttributeName':'WalkTime','type':'WALK','useHierarchy':false,'uturnAtJunctions':'esriNFSBAllowBacktrack'}"
-d "problem_type=Maximize Attendance" \
-d "number_of_facilities_to_find=2" \
-d "travel_direction=Demand to Facility"
Response (JSON)
1
2
3
4
{
"jobId": "j64631b4afe854912bfe914d2400af60d",
"jobStatus": "esriJobSubmitted"
}
Request
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/LocationAllocation/GPServer/SolveLocationAllocation/jobs/j64631b4afe854912bfe914d2400af60d? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"
Response (JSON)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
"jobId": "j64631b4afe854912bfe914d2400af60d",
"jobStatus": "esriJobSucceeded",
"results": {
"Solve_Succeeded": {
"paramUrl": "results/Solve_Succeeded"
},
"Output_Allocation_Lines": {
"paramUrl": "results/Output_Allocation_Lines"
},
"Output_Facilities": {
"paramUrl": "results/Output_Facilities"
},
"Output_Demand_Points": {
"paramUrl": "results/Output_Demand_Points"
},
"Output_Network_Analysis_Layer": {
"paramUrl": "results/Output_Network_Analysis_Layer"
},
"Output_Result_File": {
Request
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/LocationAllocation/GPServer/SolveLocationAllocation/jobs/j64631b4afe854912bfe914d2400af60d/results/Output_Facilities? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"
Response (JSON)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
{
"paramName": "Output_Facilities",
"dataType": "GPFeatureRecordSetLayer",
"value": {
"geometryType": "esriGeometryPoint",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"fields": [
// one or more field definitions
],
"features": [
{
"attributes": {
"Name": "Existing Location",
"FacilityType": 1,
"DemandCount": 10,
"DemandWeight": 23491.08198335598
// more field values
},
"geometry": {
"x": -122.33390599999996,
"y": 47.609152000000051
}
},
{
"attributes": {
"Name": "Candidate 1",
"FacilityType": 3,
"DemandCount": 8,
"DemandWeight": 20987.984012529399
// more field values
},
"geometry": {
"x": -122.33358499999997,
"y": 47.604501000000027
}
}
// more output facilities
],
"exceededTransferLimit": false
}
}
Request
1
2
3
curl https://logistics.arcgis.com/arcgis/rest/services/World/LocationAllocation/GPServer/SolveLocationAllocation/jobs/j64631b4afe854912bfe914d2400af60d/results/Output_Allocation_Lines? \
-d "f=json" \
-d "token=<ACCESS_TOKEN>"
Response (JSON)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
"paramName": "Output_Allocation_Lines",
"dataType": "GPFeatureRecordSetLayer",
"value": {
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
},
"fields": [
// one or more field definitions
],
"features": [
{
"attributes": {
"Name": "1201 Third Avenue - Existing Location",
"Weight": 1775.9506637889651,
"Total_Minutes": 3.5401683400770021
// more field values
},
"geometry": {
"paths": [
[
[
-122.33616299999994,
47.607204000000081
],
[
-122.33390599999996,
47.609152000000051
]
]
]
}
},
{
"attributes": {
"Name": "Puget Sound Plaza - Existing Location",
"Weight": 2159.2300778196532,
"Total_Minutes": 2.7793033199226498
// more field values
},
"geometry": {
"paths": [
[
Additional resources
Tutorials
Find a route and directions
Find a route and directions with the routing service.
Find service areas
Create an isochrone with driving distance with the routing service.