Skip To Content

Make Service Area Analysis Layer

Summary

Makes a service area network analysis layer and sets its analysis properties. A service area analysis layer is useful in determining the area of accessibility within a given cutoff cost from a facility location. The layer can be created using a local network dataset or using a routing 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 layers store their data on disk in file geodatabase feature classes. When creating a new 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 new 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.

Syntax

MakeServiceAreaAnalysisLayer_na (network_data_source, {layer_name}, {travel_mode}, {travel_direction}, {cutoffs}, {time_of_day}, {time_zone}, {output_type}, {polygon_detail}, {geometry_at_overlaps}, {geometry_at_cutoffs}, {polygon_trim_distance}, {exclude_sources_from_polygon_generation}, {accumulate_attributes})
ParameterExplanationData 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)

Name of the network analysis layer to create.

String
travel_mode
(Optional)

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 to or from the facilities.

  • FROM_FACILITIESThe service area represents traveling away from the facilities. This is the default.
  • TO_FACILITIESThe service area represents traveling towards the facilities.

Using this option can result in different service areas on a network with one-way restrictions and having different impedances based on direction of travel. The service area for a pizza delivery store, for example, should be created away from the facility, whereas the service area of a hospital should be created toward the facility.

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

The extent of the service area to be calculated in the units of the impedance attribute used by your selected travel mode. For example, when analyzing driving time, a cutoff value of 10 means that the resulting service area will represent the area reachable within a 10-minute drive time.

Multiple cutoffs can be set in order to create concentric service areas. For instance, to find 2-, 3-, and 5-minute service areas for the same facility, specify 2, 3, and 5 as the values for this parameter.

This default cutoff value can be overridden on a per-facility basis by specifying individual break values in the facilities sublayer.

Double
time_of_day
(Optional)

The time to depart from or arrive at the facilities of the service area layer. The interpretation of this value as a departure or arrival time depends on whether travel is away from or toward the facilities.

  • It represents the departure time if travel_direction='FROM_FACILITIES' .
  • It represents the arrival time if travel_direction='TO_FACILITIES'.

The time_of_day parameter is most useful for finding the roads that can be reached based on a travel_mode that uses an impedance attribute that varies with the time of the day, such as one based on dynamic traffic conditions. Solving the same analysis using different time_of_day values allows you to see how a facility's reach changes over time. For instance, the five-minute service area around a fire station may start out large in the early morning, diminish during the morning rush hour, grow in the late morning, and so on throughout the day.

A date and time can be specified as 10/21/2015 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
For example, to specify that travel should begin at 5:00 p.m. on Tuesday, specify the parameter value as 1/2/1900 5:00 PM.

Date
time_zone
(Optional)

Specifies the time zone of the time of day parameter.

  • LOCAL_TIME_AT_LOCATIONSThe time of day parameter refers to the time zone or zones in which the facilities are located. Therefore, the start or end times of the service areas are staggered by time zone. This is the default.For example, setting time of day to 9:00 a.m. causes service areas to be generated for 9:00 a.m. Eastern Time for any facilities in the Eastern Time Zone, 9:00 a.m. Central Time for facilities in the Central Time Zone, 9:00 a.m. Mountain Time for facilities in the Mountain Time Zone, and so on. If stores in a chain that span the U.S. open at 9:00 a.m. local time, this parameter value could be chosen to find market territories at opening time for all stores in one solve. First, the stores in the Eastern Time Zone open and a polygon is generated, then an hour later, stores open in Central Time, and so on. Nine o'clock is always in local time but staggered in real time.
  • UTCThe time of day parameter refers to Coordinated Universal Time (UTC). Therefore, all facilities are reached or departed from simultaneously, regardless of the time zone or zones they are in.Setting time of day to 2:00 p.m. causes service areas to be generated for 9:00 a.m. Eastern Standard Time for any facilities in the Eastern Time Zone, 8:00 a.m. Central Standard Time for facilities in the Central Time Zone, 7:00 a.m. Mountain Standard Time for facilities in the Mountain Time Zone, and so on.
    Note:

    The scenario above assumes standard time. During daylight saving time, the Eastern, Central, and Mountain Times would each be one hour ahead (that is, 10:00, 9:00, and 8:00 a.m., respectively).

    One of the cases in which the UTC option is useful is to visualize emergency response coverage for a jurisdiction that is split into two time zones. The emergency vehicles are loaded as facilities. Time of day is set to now in UTC. (You need to determine what the current time and date are in terms of UTC to correctly use this option.) Other properties are set and the analysis is solved. Even though a time-zone boundary divides the vehicles, the results show areas that can be reached given current traffic conditions. This same process can be used for other times as well, not just for now.
String
output_type
(Optional)

Specifies the type of output to be generated. Service area output can be line features representing the roads reachable before the cutoffs are exceeded or the polygon features encompassing these lines (representing the reachable area).

  • POLYGONSThe service area output will contain polygons only. This is the default. This is the only choice if the network data source is a service.
  • LINESThe service area output will contain lines only.
  • POLYGONS_AND_LINESThe service area output will contain both polygons and lines.
String
polygon_detail
(Optional)

Specifies the level of detail of the output polygons.

  • STANDARDCreates polygons with a standard level of detail. This is the default.
  • GENERALIZEDCreates generalized polygons using the hierarchy present in the network data source in order to produce results quickly.
  • HIGHCreates polygons with a higher level of detail for applications in which very precise results are important.

If your analysis covers an urban area with a grid-like street network, the difference between generalized and standard polygons will be minimal. However, for mountain and rural roads, the standard and detailed polygons may present significantly more accurate results than generalized polygons,

String
geometry_at_overlaps
(Optional)

Specifies the behavior of service-area output from multiple facilities in relation to one another.

  • OVERLAPCreates individual polygons or sets of lines for each facility. The polygons or lines can overlap each other. This is the default.
  • DISSOLVEJoins the polygons of multiple facilities that have the same cutoff value into a single polygon. This setting does not apply to line output.
  • SPLITArea is assigned to the closest facility so polygons or lines do not overlap each other.
String
geometry_at_cutoffs
(Optional)

Specifies the behavior of service area output for a single facility when multiple cutoff values are specified. This parameter does not apply to line output.

  • RINGSEach polygon includes only the area between consecutive cutoff values. It does not include the area between the facility and any smaller cutoffs. For instance, If you create 5- and 10-minute service areas, then the 5-minute service area polygon will include the area reachable in 0–5 minutes, and the 10-minute service area polygon will include the area reachable between 5 and 10 minutes. This is the default.
  • DISKSEach polygon includes the area reachable from the facility up to the cutoff value, including the area reachable within smaller cutoff values. For instance, If you create 5- and 10-minute service areas, then the 10-minute service area polygon will include the area under the 5-minute service area polygon.
String
polygon_trim_distance
(Optional)

Specifies the service area polygon trim distance. The polygon trim refers to the distance from the road the service area polygon should extend when no other reachable roads are nearby, similar to a line buffer size. This is useful if the network is very sparse and you don't want the service area to cover large areas where there are no features.

The parameter includes a value and units for the distance. The default value is 100 meters.

Linear Unit
exclude_sources_from_polygon_generation
[exclude_sources_from_polygon_generation,...]
(Optional)

Specifies the list of network sources to be excluded when generating the polygons. The geometry of traversed elements from the excluded sources will be omitted from all polygons.

This is useful if you have some network sources that you don't want to be included in the polygon generation because they create less accurate polygons or are inconsequential for the service area analysis. For example, while creating a walk-time service area in a multimodal network that includes streets and metro lines, you should choose to exclude the metro lines from polygon generation. Although the traveler can use the metro lines, they cannot stop partway along a metro line and enter a nearby building. Instead, they must travel the full length of the metro line, exit the metro system at a station, and then use the streets to walk to the building. It would be inaccurate to generate a polygon feature around a metro line.

Excluding a network source from service area polygons does not prevent those sources from being traversed. Excluding sources from service area polygons only influences the polygon shape of the service areas. If you want to prevent traversal of a given network source, you must create an appropriate restriction when defining your network dataset.

This parameter is not available if the network data source is a service.

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

List of cost attributes to be accumulated during analysis. These accumulated attributes are purely for reference; the solver only uses the cost attribute used by your designated travel mode when solving your 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 a service.

String

Code sample

MakeServiceAreaAnalysisLayer example 1 (Python window)

Execute the tool using only the required parameters.

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

Execute the tool using all parameters.

network = "C:/Data/Paris.gdb/Transportation/ParisMultimodal_ND"
arcpy.na.MakeServiceAreaAnalysisLayer(network, "WarehouseCoverage",
                                "Driving Time", "FROM_FACILITIES", [5, 10, 15],
                                "1/1/1900 9:00 AM", "UTC", "POLYGONS",
                                "STANDARD", "DISSOLVE", "RINGS", "100 meters",
                                ["Metro_Lines", "Transfer_Stations",
                                "Transfer_Street_Station"], ["Meters", 
                                "DriveTime"])
MakeServiceAreaAnalysisLayer example 3 (workflow)

The following stand-alone Python script demonstrates how the MakeServiceAreaAnalysisLayer tool can be used to generate a 1-, 2-, and 3-minute service area around fire stations.

# Name: MakeServiceAreaAnalysisLayer_Workflow.py
# Description: Generate 1-,2-,3- minute service areas around fire stations and
#              save the results to a layer file on disk. The service area
#              polygons can be used to visualize the areas that do not have
#              adequate coverage from the fire stations
# 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 = "FireStationCoverage"
    travel_mode = "Driving Time"
    facilities = os.path.join(input_gdb, "Analysis", "FireStations")
    output_layer_file = os.path.join(output_dir, layer_name + ".lyrx")

    #Create a new service area layer. We wish to generate the service area
    #polygons as rings, so that we can easily visualize the coverage for any
    #given location. We also want overlapping polygons so we can determine the
    #number of fire stations that cover a given location. We will specify these
    #options while creating the new service area layer.
    result_object = arcpy.na.MakeServiceAreaAnalysisLayer(network, layer_name,
                                    travel_mode, "FROM_FACILITIES", [1, 2, 3],
                                    polygon_detail="HIGH",
                                    geometry_at_overlaps="OVERLAP",
                                    geometry_at_cutoffs="RINGS")

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

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

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

    #Solve the service area layer
    arcpy.na.Solve(layer_object)

    #Save the solved service area 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))
MakeServiceAreaAnalysisLayer example 4 (workflow)

This example shows how to create service areas around facilities for multiple times of the day as well as how to port fields from the input features to the output features and append output polygons to an existing feature class.

# Name: MakeServiceAreaAnalysisLayer_Workflow2.py
# Description: Generate 3-minute service areas around fire stations at several
#               times of day to compare coverage differences due to varying
#               traffic conditions. Save the results to a feature class on disk.
# Requirements: Network Analyst Extension

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

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 = "FireStationCoverage"
    out_featureclass = os.path.join(output_dir, "Output.gdb",
                                                        "FireStationCoverage")
    travel_mode = "Driving Time"
    facilities = os.path.join(input_gdb, "Analysis", "FireStations")
    times_of_day = [datetime.datetime(2014, 9, 25, 7, 0, 0),
                    datetime.datetime(2014, 9, 25, 12, 30, 0),
                    datetime.datetime(2014, 9, 25, 17, 30, 0),
                    datetime.datetime(2014, 9, 25, 21, 0, 0)]

    #Create a new service area layer.
    result_object = arcpy.na.MakeServiceAreaAnalysisLayer(network, layer_name,
                                                travel_mode, "FROM_FACILITIES",
                                                [3], polygon_detail="HIGH",
                                                geometry_at_overlaps="OVERLAP")

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

    #Get the names of all the sublayers within the service area layer.
    sublayer_names = arcpy.na.GetNAClassNames(layer_object)
    #Stores the layer names that we will use later
    facilities_layer_name = sublayer_names["Facilities"]
    polygons_layer_name = sublayer_names["SAPolygons"]

    #The input data has a field for FireStationID that we want to transfer to
    #our analysis layer. Add the field, and then use field mapping to transfer
    #the values.
    arcpy.na.AddFieldToAnalysisLayer(layer_object, facilities_layer_name,
                                                    "FireStationID", "TEXT")
    field_mappings = arcpy.na.NAClassFieldMappings(layer_object,
                                                    facilities_layer_name)
    field_mappings["FireStationID"].mappedFieldName = "FireStationID"

    #Load the fire stations as facilities.
    arcpy.na.AddLocations(layer_object, facilities_layer_name, facilities,
                            field_mappings, "")

    # Add fields to the output Polygons sublayer for later use.
    arcpy.na.AddFieldToAnalysisLayer(layer_object, polygons_layer_name,
                                        "FireStationID", "TEXT")
    arcpy.na.AddFieldToAnalysisLayer(layer_object, polygons_layer_name,
                                        "TimeOfDay", "TEXT")

    #Get sublayers to work with later
    facilities_sublayer = layer_object.listLayers(facilities_layer_name)[0]
    polygons_sublayer = layer_object.listLayers(polygons_layer_name)[0]

    #Get the Service Area Layer's solver properties. This can be used to
    #set individual properties later without re-creating the layer.
    solver_properties = arcpy.na.GetSolverProperties(layer_object)

    #Solve the Service Area for each time of day in the time list
    for t in times_of_day:

        print("Calculating service area for time of day: ", t)

        #Use the solver properties to set the time of day for the solve
        solver_properties.timeOfDay = t

        #Solve the service area layer
        arcpy.na.Solve(layer_object)

        #Transfer the FireStationID field from the input Facilities to the
        #output Polygons
        arcpy.management.AddJoin(polygons_sublayer, "FacilityID",
                                        facilities_sublayer, "ObjectID")
        #The joined fields are qualified by the feature class name of the joined
        #table, so determine the feature class names
        field_qualifier_pol = os.path.basename(polygons_sublayer.dataSource)
        target_field_name = "%s.FireStationID" % field_qualifier_pol
        field_qualifier_fac = os.path.basename(facilities_sublayer.dataSource)
        expression = "!%s.FireStationID!" % field_qualifier_fac
        arcpy.management.CalculateField(polygons_sublayer, target_field_name,
                                        expression, "PYTHON")
        arcpy.management.RemoveJoin(polygons_sublayer)

        #Populate the TimeOfDay field in the output feature class
        expression = '"' + str(t) + '"'
        arcpy.management.CalculateField(polygons_sublayer, "TimeOfDay",
                                            expression, "PYTHON")

        #Append the polygons to the output feature class. If this was the first
        #solve, create the feature class.
        if not arcpy.Exists(out_featureclass):
            arcpy.management.CopyFeatures(polygons_sublayer, out_featureclass)
        else:
            arcpy.management.Append(polygons_sublayer, out_featureclass)

    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