Location-allocation

Location-allocation example

The best location for a new fast-food restaurant that can serve additional customers. The location-allocation service can allocate demand to existing locations (the restaurant location shown with the black filled circle) and can help you find one or more new locations (the restaurant location shown with a star) that can maximize the number of customers that can walk to your restaurant.

What is location-allocation?

Location-allocation is the process of finding a set of facilities that will best serve demand from surrounding areas. As the name suggests, location-allocation is a two-fold problem that simultaneously locates facilities and allocates demand points to the facilities.

You can use location-allocation to build applications that answer questions such as:

  • Given a set of existing fire stations, which site for a new fire station would provide the best response times for the community?
  • If a retail company has to downsize, which stores should it close to maximize the overall demand?
  • Where should a factory be built to minimize the distance to distribution centers?

How location-allocation works

The typical workflow for location-allocation analysis is to define:

  1. One or more locations that serve as facilities.
  2. One or more locations that represent demand for the services offered at the facilities.
  3. The type of travel for the analysis.
  4. The objective of the location-allocation analysis such as maximize the attendance or minimize the travel time.
  5. Number of facilities the service should choose.
  6. Call the service to find the best locations for the facilities and allocate demand to the chosen facilities.

URL requests

You can perform location allocation by making an HTTPS request to the location-allocation service submitJob operation or by using client APIs. Specify one or more facilities, demand points, the location-allocation problem type, and additional parameters to refine the operation. Some of the most common parameters are described below.

Location-allocation only supports job requests.

URL

Use dark colors for code blocksCopy
1
https://logistics.arcgis.com/arcgis/rest/services/World/LocationAllocation/GPServer/SolveLocationAllocation/submitJob?<parameters>

Required parameters

NameDescriptionExamples
fThe format of the data returned.f=json f=pjson
tokenAn API key or OAuth 2.0 access token. Learn how to get an access token in Security and authentication.token=<YOUR_API_KEY>
token=<ACCESS_TOKEN>

Key parameters

NameDescriptionExamples
facilitiesOne or more locations that serve as facilities.facilities={"features":[{"geometry":{"x":-117.195696,"y":34.056503}}]}
demand_pointsOne or more locations that represent demand for the services offered at the facilities.demand_points={"features":[{"geometry":{"x":-117.190774,"y":34.057301}},{"geometry":{"x":-117.199781,"y":34.06047}}]}
travel_modeThe mode of transportation such as driving a car or a truck or walking.travelMode=JSON Object
problem_typeThe objective of the location-allocation analysisproblem_type=Maximize Attendance
number_of_facilities_to_findNumber of facilities the service should choosenumber_of_facilities_to_find=2

Additional parameters: Set additional constraints when performing location-allocation such as default_measurement_cutoff to limit the travel time or travel distance between a facility and a demand point, ortravel_direction to indicate if travel occurs from facility to demand points or vice versa.

Code examples

Job: Find new restaurant location

In this example, the best location for a new fast-food restaurant is found to serve additional customers. A restaurant already exists in the downtown central business district that is popular with employees who work at the nearby offices. You want to expand your business by opening one more branch that can cater to more employees from nearby office buildings.

To solve this problem using the location-allocation service, you need to provide the appropriate inputs to the service that are described below:

  • The office buildings are the demand_points. They have a field called Weight that represents the number of people working in those buildings and so can be your potential customers.

  • The existing and prospective locations for the restaurants are the facilities. As you still want to run the existing restaurant, the FacilityType value for this location is 1 so that the location-allocation service will always include this facility in the final solution. You have identified four other potential locations where you can start a new branch of your restaurant. The FacilityType on these four locations is 0 so that the location-allocation service will select the best from these four in addition to the existing location.

  • The customers are walking to your restaurant. So you set the travel_mode as walking time.

  • Location-allocation service supports various problem types that have different goals. Picking the correct problem type is important to get expected results. In this scenario, you want to chose the new location such that it can attract maximum number of customers that are closest to new location so that they don't have to walk a lot to reach your restaurant from their offices. So you need to select the Maximize Attendance problem type as it is designed to achieve this goal.

  • You need to find one new restaurant location in addition to the existing location. So you set the number_of_facilities_to_find as 2. The location-allocation service will first allocate the customers to the existing restaurant and then allocate the remaining customers to the best location out of the four candidates that you have selected.

  • The travel_direction is set as Demand To Facility since the customers will be visiting the restaurant from their offices.


APIs

ArcGIS API for Python
Expand
Use dark colors for code blocksCopy
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_API_KEY"
    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

Unlike Direct request type which allows you to make a request and get back all the results in the response, when working with a Job request type, you need to follow a three step workflow:

  1. Make the submitJob request with the appropriate request parameters to get a job id.
  2. Using the job id, check the job status to see if the job completed successfully.
  3. Use the job id to get one or more results.
cURLcURLHTTP
Use dark colors for code blocksCopy
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)
Use dark colors for code blocksCopy
1
2
3
4
{
  "jobId": "j64631b4afe854912bfe914d2400af60d",
  "jobStatus": "esriJobSubmitted"
}

Tutorials

Services

Routing service

Get turn-by-turn directions and solve advanced routing problems.

API support

RoutingOptimized RoutingFleet routingClosest facility routingService areasLocation-allocationTravel cost matrix
ArcGIS Maps SDK for JavaScript111
ArcGIS Maps SDK for .NET111
ArcGIS Maps SDK for Kotlin111
ArcGIS Maps SDK for Swift111
ArcGIS Maps SDK for Java111
ArcGIS Maps SDK for Qt111
ArcGIS API for Python
ArcGIS REST JS
Esri Leaflet2222222
MapLibre GL JS2222222
OpenLayers2222222
Full supportPartial supportNo support
  • 1. Access with geoprocessing task.
  • 2. Access via ArcGIS REST JS.

Tools

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.