Available with Network Analyst license.

## Summary

Makes a location-allocation network analysis layer and sets its analysis properties. A location-allocation analysis layer is useful for choosing a given number of facilities from a set of potential locations such that a demand will be allocated to facilities in an optimal and efficient manner.

## Usage

After creating the analysis layer with this tool, you can add network analysis objects to it using the Add Locations tool, solve the analysis using the Solve tool, and save the results on disk using the Save To Layer File tool.

When using this tool in geoprocessing models, if the model is run as a tool, the output network analysis layer must be made a model parameter; otherwise, the output layer is not added to the contents of the map.

## Syntax

MakeLocationAllocationLayer_na (in_network_dataset, out_network_analysis_layer, impedance_attribute, {loc_alloc_from_to}, {loc_alloc_problem_type}, {number_facilities_to_find}, {impedance_cutoff}, {impedance_transformation}, {impedance_parameter}, {target_market_share}, {accumulate_attribute_name}, {UTurn_policy}, {restriction_attribute_name}, {hierarchy}, {output_path_shape}, {default_capacity}, {time_of_day})

Parameter | Explanation | Data Type |

in_network_dataset | The network dataset on which the location-allocation analysis will be performed. | Network Dataset Layer |

out_network_analysis_layer | Name of the location-allocation network analysis layer to create. | String |

impedance_attribute | The cost attribute to be used as impedance in the analysis. | String |

loc_alloc_from_to (Optional) | Specifies the direction of travel between facilities and demand points when calculating the network costs. - FACILITY_TO_DEMAND —Direction of travel is from facilities to demand points. Fire departments commonly use the this setting, since they are concerned with the time it takes to travel from the fire station to the location of the emergency.
- DEMAND_TO_FACILITY —Direction of travel is from demand points to facilities. Retail stores commonly use this setting, since they are concerned with the time it takes the shoppers to reach the store.
Using this option can affect the allocation of the demand points to the facilities on a network with one-way restrictions and different impedances based on direction of travel. For instance, a facility may be a 15-minute drive from the demand point to the facility, but only a 10-minute trip when traveling from the facility to the demand point. | String |

loc_alloc_problem_type (Optional) | The problem type that will be solved. The choice of the problem type depends on the kind of facility being located. Different kinds of facilities have different priorities and constraints. - MINIMIZE_IMPEDANCE —This option solves the warehouse location problem. It selects a set of facilities such that the total sum of weighted impedances (demand at a location times the impedance to the closest facility) is minimized. This problem type is often known as the P-Median problem.
- MAXIMIZE_COVERAGE —This option solves the fire station location problem. It chooses facilities such that all or the greatest amount of demand is within a specified impedance cutoff.
- MAXIMIZE_CAPACITATED_COVERAGE —This option solves the location problem where facilities have a finite capacity. It chooses facilities such that all or the greatest amount of demand can be served without exceeding the capacity of any facility. In addition to honoring capacity, it selects facilities such that the total sum of weighted impedance (demand allocated to a facility multiplied by the impedance to or from the facility) is minimized.
- MINIMIZE_FACILITIES —This option solves the fire station location problem. It chooses the minimum number of facilities needed to cover all or the greatest amount of demand within a specified impedance cutoff.
- MAXIMIZE_ATTENDANCE —This option solves the neighborhood store location problem where the proportion of demand allocated to the nearest chosen facility falls with increasing distance. The set of facilities that maximize the total allocated demand is chosen. Demand further than the specified impedance cutoff does not affect the chosen set of facilities.
- MAXIMIZE_MARKET_SHARE —This option solves the competitive facility location problem. It chooses facilities to maximize market share in the presence of competitive facilities. Gravity model concepts are used to determine the proportion of demand allocated to each facility. The set of facilities that maximizes the total allocated demand is chosen.
- TARGET_MARKET_SHARE —This option solves the competitive facility location problem. It chooses facilities to reach a specified target market share in the presence of competitive facilities. Gravity model concepts are used to determine the proportion of demand allocated to each facility. The minimum number of facilities needed to reach the specified target market share is chosen.
| String |

number_facilities_to_find (Optional) | Specifies the number of facilities that the solver should locate. The facilities with a FacilityType value of Required are always part of the solution when there are more facilities to find than required facilities; any excess facilities to choose are picked from candidate facilities. Any facilities that have a FacilityType value of Chosen before solving are treated as candidate facilities at solve time. The parameter value is not considered for the MINIMIZE_FACILITIES problem type since the solver determines the minimum number of facilities to locate to maximize coverage. The parameter value is overridden for the TARGET_MARKET_SHARE problem type because the solver searches for the minimum number of facilities required to capture the specified market share. | Long |

impedance_cutoff (Optional) |
Impedance Cutoff specifies the maximum impedance at which a demand point can be allocated to a facility. The maximum impedance is measured by the least-cost path along the network. If a demand point is outside the cutoff, it is left unallocated. This property might be used to model the maximum distance that people are willing to travel to visit your stores or the maximum time that is permitted for a fire department to reach anyone in the community. Demand points have a Cutoff_[Impedance] property, which, if set, overrides the Impedance Cutoff property of the analysis layer. You might find that people in rural areas are willing to travel up to 10 miles to reach a facility, while urbanites are only willing to travel up to 2 miles. You can model this behavior by setting the impedance cutoff value of the analysis layer to 10 and setting the Cutoff_Miles value of the demand points in urban areas to 2. | Double |

impedance_transformation (Optional) | This sets the equation for transforming the network cost between facilities and demand points. This property, coupled with the Impedance Parameter, specifies how severely the network impedance between facilities and demand points influences the solver's choice of facilities. - LINEAR —The transformed network impedance between the facility and the demand point is the same as the shortest-path network impedance between them. With this option, the impedance parameter is always set to one. This is the default.
- POWER —The transformed network impedance between the facility and the demand point is equal to the shortest-path network impedance raised to the power specified by the impedance parameter. Use this option with a positive impedance parameter to specify higher weight to nearby facilities.
- EXPONENTIAL —The transformed network impedance between the facility and the demand point is equal to the mathematical constant e raised to the power specified by the shortest-path network impedance multiplied with the impedance parameter. Use this option with a positive impedance parameter to specify a very high weight to nearby facilities.Exponential transformations are commonly used in conjunction with an impedance cutoff.
Demand points have an ImpedanceTransformation property, which, if set, overrides the Impedance Transformation property of the analysis layer. You might determine the impedance transformation should be different for urban and rural residents. You can model this by setting the impedance transformation for the analysis layer to match that of rural residents and setting the impedance transformation for the demand points in urban areas to match that of urbanites. | String |

impedance_parameter (Optional) | Provides a parameter value to the equations specified in the Impedance transformation parameter. The parameter value is ignored when the impedance transformation is of type LINEAR. For POWER and EXPONENTIAL impedance transformations, the value should be nonzero. Demand points have an ImpedanceParameter property, which, if set, overrides the Impedance Parameter property of the analysis layer. You might determine that the impedance parameter should be different for urban and rural residents. You can model this by setting the impedance transformation for the analysis layer to match that of rural residents and setting the impedance transformation for the demand points in urban areas to match that of urbanites. | Double |

target_market_share (Optional) | Specifies the target market share in percentage to solve for when the Location-Allocation Problem Type parameter is set to TARGET_MARKET_SHARE . It is the percentage of the total demand weight that you want your solution facilities to capture. The solver chooses the minimum number of facilities required to capture the target market share specified by this numeric value. | Double |

accumulate_attribute_name [accumulate_attribute_name,...] (Optional) | List of cost attributes to be accumulated during analysis. These accumulation attributes are purely for reference; the solver only uses the cost attribute specified by the Impedance Attribute parameter to calculate the route. For each cost attribute that is accumulated, a Total_[Impedance] property is added to the routes that are output by the solver. | String |

UTurn_policy (Optional) | The U-Turn policy at junctions. Allowing U-turns implies the solver can turn around at a junction and double back on the same street. Given that junctions represent street intersections and dead ends, different vehicles may be able to turn around at some junctions but not at others—it depends on whether the junction represents an intersection or dead end. To accommodate, the U-turn policy parameter is implicitly specified by how many edges connect to the junction, which is known as junction valency. The acceptable values for this parameter are listed below; each is followed by a description of its meaning in terms of junction valency. - ALLOW_UTURNS —U-turns are permitted at junctions with any number of connected edges. This is the default value.
- NO_UTURNS —U-turns are prohibited at all junctions, regardless of junction valency. Note, however, that U-turns are still permitted at network locations even when this setting is chosen; however, you can set the individual network location's CurbApproach property to prohibit U-turns there as well.
- ALLOW_DEAD_ENDS_ONLY —U-turns are prohibited at all junctions, except those that have only one adjacent edge (a dead end).
- ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLY —U-turns are prohibited at junctions where exactly two adjacent edges meet but are permitted at intersections (junctions with three or more adjacent edges) and dead ends (junctions with exactly one adjacent edge). Often, networks have extraneous junctions in the middle of road segments. This option prevents vehicles from making U-turns at these locations.
| String |

restriction_attribute_name [restriction_attribute_name,...] (Optional) | List of restriction attributes to apply during the analysis. | String |

hierarchy (Optional) | - USE_HIERARCHY — Use the hierarchy attribute for the analysis. Using a hierarchy results in the solver preferring higher-order edges to lower-order edges. Hierarchical solves are faster, and they can be used to simulate the preference of a driver who chooses to travel on freeways over local roads when possible—even if that means a longer trip. This option is valid only if the input network dataset has a hierarchy attribute.
- NO_HIERARCHY —Do not use the hierarchy attribute for the analysis. Not using a hierarchy yields an exact route for the network dataset.
The parameter is not used if a hierarchy attribute is not defined on the network dataset used to perform the analysis. In such cases, use "#" as the parameter value. | Boolean |

output_path_shape (Optional) | - NO_LINES —No shape will be generated for the output of the analysis.
- STRAIGHT_LINES —The output line shapes will be straight lines connecting the solution facilities to their allocated demand points.
| String |

default_capacity (Optional) | Specifies the default capacity of facilities when the loc_alloc_problem_type parameter is set to MAXIMIZE_CAPACITATED_COVERAGE. This parameter is ignored for all other problem types. Facilities have a Capacity property, which, if set to a nonnull value, overrides the default_capacity parameter for that facility. | Double |

time_of_day (Optional) | Indicates the time and date of departure. The departure time can be from facilities or demand points, depending on whether travel is from demand to facility or facility to demand. If you have chosen a traffic-based impedance attribute, the solution will be generated given dynamic traffic conditions at the time of day specified here. A date and time can be specified as 5/14/2012 10:30 AM. Instead of using a particular date, a day of the week can be specified using the following dates. - Today—12/30/1899
- Sunday—12/31/1899
- Monday—1/1/1900
- Tuesday—1/2/1900
- Wednesday—1/3/1900
- Thursday—1/4/1900
- Friday—1/5/1900
- Saturday—1/6/1900
| Date |

## Code sample

##### MakeLocationAllocationLayer example 1 (Python window)

Execute the tool using only the required parameters.

```
network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
arcpy.na.MakeLocationAllocationLayer(network, "StoreLocations", "TravelTime")
```

##### MakeLocationAllocationLayer example 2 (Python window)

Execute the tool using all parameters.

```
network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
arcpy.na.MakeLocationAllocationLayer(network, "NewStores", "TravelTime",
"DEMAND_TO_FACILITY", "MAXIMIZE_ATTENDANCE",
3, 5, "POWER", 2, "",
["TravelTime", "Meters"], "ALLOW_UTURNS",
["Oneway"], "NO_HIERARCHY",
"STRAIGHT_LINES", "", "9 AM")
```

##### MakeLocationAllocationLayer example 3 (workflow)

The following stand-alone Python script demonstrates how the MakeLocationAllocationLayer tool can be used to choose the store locations that would generate the most business for a retail chain.

```
# Name: MakeLocationAllocationLayer_Workflow.py
# Description: Choose the store locations that would generate the most business
# for a retail chain. For this scenario we will perform the
# location-allocation analysis using maximize attendance problem
# type.
# Requirements: Network Analyst Extension
#Import system modules
import arcpy
from arcpy import env
try:
#Check out the Network Analyst extension license
arcpy.CheckOutExtension("Network")
#Set environment settings
env.workspace = "C:/data/SanFrancisco.gdb"
env.overwriteOutput = True
#Set local variables
inNetworkDataset = "Transportation/Streets_ND"
outNALayerName = "NewStoreLocations"
impedanceAttribute = "TravelTime"
inFacilities = "Analysis/CandidateStores"
requiredFacility = "Analysis/ExistingStore"
inDemandPoints = "Analysis/TractCentroids"
outLayerFile = "C:/data/output" + "/" + outNALayerName + ".lyr"
#Create a new location-allocation layer. In this case the demand travels to
#the facility. We wish to find 3 potential store locations out of all the
#candidate store locations using the maximize attendance model.
outNALayer = arcpy.na.MakeLocationAllocationLayer(inNetworkDataset,
outNALayerName,
impedanceAttribute,
"DEMAND_TO_FACILITY",
"MAXIMIZE_ATTENDANCE",3,5,
"LINEAR")
#Get the layer object from the result object. The location-allocation layer
#can now be referenced using the layer object.
outNALayer = outNALayer.getOutput(0)
#Get the names of all the sublayers within the location-allocation layer.
subLayerNames = arcpy.na.GetNAClassNames(outNALayer)
#Stores the layer names that we will use later
facilitiesLayerName = subLayerNames["Facilities"]
demandPointsLayerName = subLayerNames["DemandPoints"]
#Load the candidate store locations as facilities using default search
#tolerance and field mappings.
arcpy.na.AddLocations(outNALayer, facilitiesLayerName, inFacilities, "", "",
exclude_restricted_elements = "EXCLUDE")
#Load the existing store location as the required facility. Use the field
#mappings to set the facility type to requried. We need to append this
#required facility to existing facilities.
fieldMappings = arcpy.na.NAClassFieldMappings(outNALayer, facilitiesLayerName)
fieldMappings["FacilityType"].defaultValue = 1
arcpy.na.AddLocations(outNALayer, facilitiesLayerName, requiredFacility,
fieldMappings, "", append = "APPEND",
exclude_restricted_elements = "EXCLUDE")
#Load the tract centroids as demand points using default search tolerance
#Use the field mappings to map the Weight property from POP2000 field.
demandFieldMappings = arcpy.na.NAClassFieldMappings(outNALayer,
demandPointsLayerName)
demandFieldMappings["Weight"].mappedFieldName = "POP2000"
arcpy.na.AddLocations(outNALayer,demandPointsLayerName ,inDemandPoints,
demandFieldMappings, "",
exclude_restricted_elements = "EXCLUDE")
#Solve the location-allocation layer
arcpy.na.Solve(outNALayer)
#Save the solved location-allocation layer as a layer file on disk with
#relative paths
arcpy.management.SaveToLayerFile(outNALayer,outLayerFile,"RELATIVE")
print "Script completed successfully"
except Exception as e:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
print "An error occurred on line %i" % tb.tb_lineno
print str(e)
```

## Environments

## Licensing information

- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes