Make Location-Allocation Analysis Layer (Network Analyst)

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. The layer can be created using a local network dataset or using a service hosted online or in a portal.

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.

  • In ArcGIS Pro, network analysis layer data is stored on disk in file geodatabase feature classes. When creating a network analysis layer in a project, the layer's data will be created in a new feature dataset in the Current Workspace environment. When creating a network analysis layer in a Python script, you must first explicitly set the workspace environment to a file geodatabase where you want the layer's data to be stored using arcpy.env.workspace = "<path to file gdb>". When the layer is created, a new feature dataset containing the appropriate sublayer feature classes will be added to this file geodatabase.

Parameters

LabelExplanationData Type
Network Data Source

The network dataset or service on which the network analysis will be performed. Use the portal URL for a service.

Network Dataset Layer;String
Layer Name
(Optional)

The name of the network analysis layer to create.

String
Travel Mode
(Optional)

The name of the travel mode to use in the analysis. The travel mode represents a collection of network settings, such as travel restrictions and U-turn policies, that determine how a pedestrian, car, truck, or other medium of transportation moves through the network. Travel modes are defined on your network data source.

An arcpy.na.TravelMode object and a string containing the valid JSON representation of a travel mode can also be used as input to the parameter.

String
Travel Direction
(Optional)

Specifies the direction of travel between facilities and demand points when calculating the network costs.

  • Away from facilities — Direction of travel is from facilities to demand points. This is the default. Fire departments commonly use this setting, since they are concerned with the time it takes to travel from the fire station to the location of the emergency.
  • Toward facilities — 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.
String
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. This is the default problem type.
  • 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
Cutoff
(Optional)

The maximum impedance at which a demand point can be allocated to a facility in the units of the impedance attribute used by your chosen Travel Mode. 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.

This cutoff can be overridden on a per-demand-point basis by specifying individual cutoff values in the demand points sublayer in the Cutoff_[Impedance] property. For example, 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 Cutoff value of the analysis layer to 10 and setting the Cutoff_Miles value of each demand point in an urban areas to 2.

By default, no cutoff is used for the analysis.

Double
Number of Facilities to Find
(Optional)

Specifies the number of facilities that the solver should locate. By default, this parameter is set to 1.

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
Decay Function Type
(Optional)

This sets the equation for transforming the network cost between facilities and demand points. This property, coupled with the Decay Function Parameter Value, 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 1. 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.
String
Decay Function Parameter Value
(Optional)

Provides a parameter value to the equations specified in the Decay Function Type parameter. The parameter value is ignored when the decay function is of type Linear. For Power and Exponential decay functions, the value should be nonzero.

Demand points have an ImpedanceTransformation property, which, if set, overrides the Decay Function Parameter Value property of the analysis layer on a per-demand-point basis. You might determine that the decay function 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 individual demand points located 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 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
Capacity
(Optional)

Specifies the default capacity of facilities when the 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 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 Direction 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
Time Zone
(Optional)

The time zone of the Time of Day parameter.

  • Local time at locations —The Time of Day parameter refers to the time zone in which the facilities or demand points are located. If Travel Direction is facilities to demand points, this is the time zone of the facilities. If Travel Direction is demand points to facilities, this is the time zone of the demand points. This is the default.
  • UTC —The Time of Day parameter refers to Coordinated Universal Time (UTC). Choose this option if you want to choose the best location for a specific time, such as now, but aren't certain in which time zone the facilities or demand points will be located.
String
Line Shape
(Optional)

No matter which output shape type is chosen, the best route is always determined by the network impedance, never Euclidean distance. This means that only the route shapes are different, not the underlying traversal of the network.

  • No lines — No shape will be generated for the output of the analysis. This is useful if you are solving a very large problem and are interested only in solution table and are not interested in visualizing your results in a map.
  • Straight lines — The output line shapes will be straight lines connecting the solution facilities to their allocated demand points. This is the default.
String
Accumulate Attributes
(Optional)

A list of cost attributes to be accumulated during analysis. These accumulated attributes are for reference only; the solver only uses the cost attribute used by your designated travel mode when solving the analysis.

For each cost attribute that is accumulated, a Total_[Impedance] property is populated in the network analysis output features.

This parameter is not available if the network data source is an ArcGIS Online service or the network data source is a service on a version of Portal for ArcGIS that does not support accumulation.

String

Derived Output

LabelExplanationData Type
Network Analyst Layer

The newly created network analysis layer.

Network Analyst Layer

arcpy.na.MakeLocationAllocationAnalysisLayer(network_data_source, {layer_name}, {travel_mode}, {travel_direction}, {problem_type}, {cutoff}, {number_of_facilities_to_find}, {decay_function_type}, {decay_function_parameter_value}, {target_market_share}, {capacity}, {time_of_day}, {time_zone}, {line_shape}, {accumulate_attributes})
NameExplanationData Type
network_data_source

The network dataset or service on which the network analysis will be performed. Use the portal URL for a service.

Network Dataset Layer;String
layer_name
(Optional)

The name of the network analysis layer to create.

String
travel_mode
(Optional)

The name of the travel mode to use in the analysis. The travel mode represents a collection of network settings, such as travel restrictions and U-turn policies, that determine how a pedestrian, car, truck, or other medium of transportation moves through the network. Travel modes are defined on your network data source.

An arcpy.na.TravelMode object and a string containing the valid JSON representation of a travel mode can also be used as input to the parameter.

String
travel_direction
(Optional)

Specifies the direction of travel between facilities and demand points when calculating the network costs.

  • FROM_FACILITIESDirection of travel is from facilities to demand points. This is the default. Fire departments commonly use this setting, since they are concerned with the time it takes to travel from the fire station to the location of the emergency.
  • TO_FACILITIESDirection 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, it may take 15 minutes to drive from the demand point to the facility but only 10 minutes when driving from the facility to the demand point.

String
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_IMPEDANCEThis 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. This is the default problem type.
  • MAXIMIZE_COVERAGEThis 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_COVERAGEThis 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_FACILITIESThis 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_ATTENDANCEThis 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_SHAREThis 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_SHAREThis 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
cutoff
(Optional)

The maximum impedance at which a demand point can be allocated to a facility in the units of the impedance attribute used by your chosen Travel Mode. 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.

This cutoff can be overridden on a per-demand-point basis by specifying individual cutoff values in the demand points sublayer in the Cutoff_[Impedance] property. For example, 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 Cutoff value of the analysis layer to 10 and setting the Cutoff_Miles value of each demand point in an urban areas to 2.

By default, no cutoff is used for the analysis.

Double
number_of_facilities_to_find
(Optional)

Specifies the number of facilities that the solver should locate. By default, this parameter is set to 1.

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
decay_function_type
(Optional)

This sets the equation for transforming the network cost between facilities and demand points. This property, coupled with the Decay Function Parameter Value, specifies how severely the network impedance between facilities and demand points influences the solver's choice of facilities.

  • LINEARThe 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 1. This is the default.
  • POWERThe 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.
  • EXPONENTIALThe 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 Decay Function Parameter Value property of the analysis layer on a per-demand-point basis. You might determine that the decay function 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 individual demand points located in urban areas to match that of urbanites.

String
decay_function_parameter_value
(Optional)

Provides a parameter value to the equations specified in the decay_function_type parameter. The parameter value is ignored when the decay function is of type LINEAR. For POWER and EXPONENTIAL decay functions, the value should be nonzero.

Demand points have an ImpedanceTransformation property, which, if set, overrides the decay_function_parameter_value property of the analysis layer on a per-demand-point basis. You might determine that the decay function 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 individual demand points located 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 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
capacity
(Optional)

Specifies the default capacity of facilities when the 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 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 Direction 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
time_zone
(Optional)

The time zone of the Time of Day parameter.

  • LOCAL_TIME_AT_LOCATIONSThe Time of Day parameter refers to the time zone in which the facilities or demand points are located. If Travel Direction is facilities to demand points, this is the time zone of the facilities. If Travel Direction is demand points to facilities, this is the time zone of the demand points. This is the default.
  • UTCThe Time of Day parameter refers to Coordinated Universal Time (UTC). Choose this option if you want to choose the best location for a specific time, such as now, but aren't certain in which time zone the facilities or demand points will be located.
String
line_shape
(Optional)
  • NO_LINESNo shape will be generated for the output of the analysis. This is useful if you are solving a very large problem and are interested only in solution table and are not interested in visualizing your results in a map.
  • STRAIGHT_LINESThe output line shapes will be straight lines connecting the solution facilities to their allocated demand points. This is the default.

No matter which output shape type is chosen, the best route is always determined by the network impedance, never Euclidean distance. This means that only the route shapes are different, not the underlying traversal of the network.

String
accumulate_attributes
[accumulate_attributes,...]
(Optional)

A list of cost attributes to be accumulated during analysis. These accumulated attributes are for reference only; the solver only uses the cost attribute used by your designated travel mode when solving the analysis.

For each cost attribute that is accumulated, a Total_[Impedance] property is populated in the network analysis output features.

This parameter is not available if the network data source is an ArcGIS Online service or the network data source is a service on a version of Portal for ArcGIS that does not support accumulation.

String

Derived Output

NameExplanationData Type
out_network_analysis_layer

The newly created network analysis layer.

Network Analyst Layer

Code sample

MakeLocationAllocationAnalysisLayer example 1 (Python window)

Execute the tool using only the required parameters.

network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
arcpy.na.MakeLocationAllocationAnalysisLayer(network, "StoreLocations")
MakeLocationAllocationAnalysisLayer example 2 (Python window)

Execute the tool using all parameters.

network = "C:/Data/SanFrancisco.gdb/Transportation/Streets_ND"
arcpy.na.MakeLocationAllocationAnalysisLayer(network, "NewStores",
                                    "Driving Time", "TO_FACILITIES",
                                    "MAXIMIZE_ATTENDANCE", 3, 5, "POWER", 2, "",
                                    "", "1/1/1900 9:00 AM", "UTC",
                                    "STRAIGHT_LINES", ["TravelTime", "Meters"])
MakeLocationAllocationAnalysisLayer example 3 (workflow)

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

# Name: MakeLocationAllocationAnalysisLayer_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 the maximize attendance
#              problem type.
# Requirements: Network Analyst Extension

#Import system modules
import arcpy
from arcpy import env
import os

try:
    #Check out Network Analyst license if available. Fail if the Network Analyst license is not available.
    if arcpy.CheckExtension("network") == "Available":
        arcpy.CheckOutExtension("network")
    else:
        raise arcpy.ExecuteError("Network Analyst Extension license is not available.")
    
    #Set environment settings
    output_dir = "C:/Data"
    #The NA layer's data will be saved to the workspace specified here
    env.workspace = os.path.join(output_dir, "Output.gdb")
    env.overwriteOutput = True

    #Set local variables
    input_gdb = "C:/Data/SanFrancisco.gdb"
    network = os.path.join(input_gdb, "Transportation", "Streets_ND")
    layer_name = "NewStoreLocations"
    travel_mode = "Driving Time"
    facilities = os.path.join(input_gdb, "Analysis", "CandidateStores")
    required_facility = os.path.join(input_gdb, "Analysis", "ExistingStore")
    demand_points = os.path.join(input_gdb, "Analysis", "TractCentroids")
    output_layer_file = os.path.join(output_dir, layer_name + ".lyrx")

    #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.
    result_object = arcpy.na.MakeLocationAllocationAnalysisLayer(network,
                                    layer_name, travel_mode, "TO_FACILITIES",
                                    "MAXIMIZE_ATTENDANCE", cutoff=20,
                                    number_of_facilities_to_find=3)

    #Get the layer object from the result object. The location-allocation layer
    #can now be referenced using the layer object.
    layer_object = result_object.getOutput(0)

    #Get the names of all the sublayers within the location-allocation layer.
    sublayer_names = arcpy.na.GetNAClassNames(layer_object)
    #Stores the layer names that we will use later
    facilities_layer_name = sublayer_names["Facilities"]
    demand_points_layer_name = sublayer_names["DemandPoints"]

    #Load the candidate store locations as facilities using default search
    #tolerance and field mappings.
    arcpy.na.AddLocations(layer_object, facilities_layer_name, facilities, "",
                                                                            "")

    #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.
    field_mappings = arcpy.na.NAClassFieldMappings(layer_object,
                                                    facilities_layer_name)
    field_mappings["FacilityType"].defaultValue = 1
    arcpy.na.AddLocations(layer_object, facilities_layer_name,
                            required_facility, field_mappings, "",
                            append="APPEND")

    #Load the tract centroids as demand points using default search tolerance
    #Use the field mappings to map the Weight property from POP2000 field.
    demand_field_mappings = arcpy.na.NAClassFieldMappings(layer_object,
                                                    demand_points_layer_name)
    demand_field_mappings["Weight"].mappedFieldName = "POP2000"
    arcpy.na.AddLocations(layer_object, demand_points_layer_name, demand_points,
                          demand_field_mappings, "")

    #Solve the location-allocation layer
    arcpy.na.Solve(layer_object)

    #Save the solved location-allocation layer as a layer file on disk
    layer_object.saveACopy(output_layer_file)

    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

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes