Location-allocation analysis identifying the best site for a new restaurant to maximize the number of customers within walking times of proposed locations.

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.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, you want to expand a popular fast-food restaurant in the downtown central business district by opening a second location for employees in nearby office buildings. Use the location-allocation service to find the best site.

Provide the following inputs to the service:

  • Customers in office buildings are the demand_points.

  • The existing and prospective restaurant locations are the facilities. Set FacilityType to 1 for the existing restaurant so the service always includes it in the solution. Set FacilityType to 0 for the four prospective locations so the service can select the best one in addition to the existing restaurant.

  • Since customers walk to the restaurant, set travel_mode to walking time.

  • Choose the problem type that matches your goal. Here, select Maximize Attendance to attract the maximum number of nearby customers and minimize their walking distance from their offices.

  • To find one new location in addition to the existing restaurant, set number_of_facilities_to_find to 2. The service first allocates customers to the existing restaurant, then assigns the remaining customers to the best of the four candidates.

  • Set travel_direction to Demand To Facility because customers travel from their offices to the restaurant.


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_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

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"
}

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