Make Last Mile Delivery Analysis Layer (Network Analyst)

Summary

Creates a last mile delivery network analysis layer and sets its analysis properties. A last mile delivery analysis layer is useful for optimizing a set of routes using a fleet of vehicles. The layer can be created using a local network dataset or a service hosted online or in a portal.

Usage

  • The analysis network used for a last mile delivery analysis must have at least one travel mode, one cost attribute with time units, and one cost attribute with distance units, as well as a time zone attribute.

  • 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.

  • Although this tool can be run in Python, a better way to automate last mile delivery workflows in Python is to use the LastMileDelivery solver object in the arcpy.nax Network Analyst module.

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.

The network must have at least one travel mode, one cost attribute with time units, and one cost attribute with distance units, as well as a time zone attribute.

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.

The travel mode's impedance attribute must have units of time.

String
Time Units
(Optional)

Specifies the time units that will be used by the analysis layer's properties and the temporal fields of the analysis layer's sublayers and tables (network analysis classes). This value does not need to match the units of the time cost attribute.

  • MinutesThe time units will be minutes. This is the default.
  • SecondsThe time units will be seconds.
  • HoursThe time units will be hours.
  • DaysThe time units will be days.
String
Distance Units
(Optional)

Specifies the distance units that will be used by the analysis layer's properties and the distance fields of the analysis layer's sublayers and tables (network analysis classes). This value does not need to match the units of the optional distance cost attribute.

Caution:
The Inches, Centimeters, Millimeters, and Decimeters options are not available when the network data source is a service.

  • MilesThe distance units will be miles. This is the default.
  • KilometersThe distance units will be kilometers.
  • FeetThe distance units will be feet.
  • YardsThe distance units will be yards.
  • MetersThe distance units will be meters.
  • InchesThe distance units will be inches.
  • CentimetersThe distance units will be centimeters.
  • MillimetersThe distance units will be millimeters.
  • DecimetersThe distance units will be decimeters.
  • Nautical MilesThe distance units will be nautical miles.
String
Earliest Route Start Date
(Optional)

The default earliest start date for routes. This date is used for all routes for which the EarliestStartDate field in the Routes sublayer is null. When no parameter value is specified, all rows in the Routes sublayer must specify a value in the EarliestStartDate field.

Although you can specify both a date and a time for this parameter, only the date is used. To set the earliest start time for routes, use the Earliest Route Start Time parameter.

Caution:
Although the other Network Analyst solvers allow you to use special dates to model a day of the week or the current date instead of a specific, static date, the last mile delivery solver does not. You must choose a specific date.

Date
Earliest Route Start Time
(Optional)

The default earliest start time for routes. This time of day is used for all routes for which the EarliestStartTime field in the Routes sublayer is null. When no parameter value is specified, all rows in the Routes sublayer must specify a value in the EarliestStartTime field.

Although you can specify both a date and a time for this parameter, only the time is used. To set the earliest start date for routes, use the Earliest Route Start Date parameter.

Date
Max Route Total Time
(Optional)

The maximum allowed total time for each route. The value can be any positive number.

The value is used for all routes for which the MaxTotalTime field in the Routes sublayer is null. When no parameter value is specified, all rows in the Routes sublayer must specify a value in the MaxTotalTime field.

The value is interpreted in the units specified in the Time Units parameter.

Double
Time Zone for Time Fields
(Optional)

Specifies the time zone that will be used for the input date-time fields supported by the tool.

Specifying the date-time values in UTC is useful if you do not know the time zone in which the orders or depots are located or when you have orders and depots in multiple time zones and you want all the date-time values to start simultaneously.

  • Local time at locations The date-time values associated with the orders or depots will be in the time zone in which the orders and depots are located. For routes, the date-time values are based on the time zone in which the starting depot for the route is located. If a route does not have a starting depot, all orders and depots across all the routes must be in a single time zone. This is the default.
  • UTCThe date-time values associated with the orders, depots, and routes will be in coordinated universal time (UTC) and are not based on the time zone in which the orders or depots are located.
String
Sequence Gap
(Optional)

The gap in numerical values to leave in the Sequence field in the Orders sublayer between adjacent orders when the analysis is solved. The value acts as a multiplier for the actual sequence of orders on each route. For example, if the gap is 5, the first order on the route will have a Sequence field value of 5, the second order on the route will have a Sequence field value of 10, the third 15, and so on. This parameter helps support inserting orders after the initial route plan has been created because the new orders can be inserted into the sequence gaps.

The value must be a positive integer. The default is 1.

The first time the analysis is solved, the Sequence field values will be populated with sequential values using the designated sequence gap. On subsequent solves of the same analysis, the Sequence field values of existing orders will be maintained, and new orders will be inserted into the gaps using available integer values for the Sequence field that are not in use by other orders. If the sequence gap is set to 1, the sequence values will always be updated to contiguous values for every solve.

Long
Ignore Invalid Order Locations on Solve
(Optional)

Specifies whether invalid order locations will be ignored.

  • Checked—Invalid order locations will be ignored so that the analysis will succeed using only valid locations.
  • Unchecked—Invalid order locations will not be ignored and will cause the analysis to fail. This is the default.
Boolean
Output Route Shape
(Optional)

Specifies the shape type that will be used for the route features that are output by the analysis.

Regardless of the output shape type specified, 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.

  • Along networkThe output routes will have the exact shape of the underlying network sources. The output includes route measurements for linear referencing. The measurements increase from the first stop and record the cumulative impedance to reach a given position.
  • No linesNo shape will be generated for the output routes.
  • Straight linesThe output route shape will be a single straight line between the stops. This is the default.
String
Generate Directions on Solve
(Optional)

Specifies whether directions will be generated when the analysis is solved.

  • Checked—Turn-by-turn directions will be generated on solve.
  • Unchecked—Turn-by-turn directions will not be generated on solve. This is the default.
Boolean

Derived Output

LabelExplanationData Type
Network Analyst Layer

The new network analysis layer.

Network Analyst Layer

arcpy.na.MakeLastMileDeliveryAnalysisLayer(network_data_source, {layer_name}, {travel_mode}, {time_units}, {distance_units}, {earliest_route_start_date}, {earliest_route_start_time}, {max_route_total_time}, {time_zone_for_time_fields}, {sequence_gap}, {ignore_invalid_order_locations}, {line_shape}, {generate_directions_on_solve})
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.

The network must have at least one travel mode, one cost attribute with time units, and one cost attribute with distance units, as well as a time zone attribute.

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.

The travel mode's impedance attribute must have units of time.

String
time_units
(Optional)

Specifies the time units that will be used by the analysis layer's properties and the temporal fields of the analysis layer's sublayers and tables (network analysis classes). This value does not need to match the units of the time cost attribute.

  • MinutesThe time units will be minutes. This is the default.
  • SecondsThe time units will be seconds.
  • HoursThe time units will be hours.
  • DaysThe time units will be days.
String
distance_units
(Optional)

Specifies the distance units that will be used by the analysis layer's properties and the distance fields of the analysis layer's sublayers and tables (network analysis classes). This value does not need to match the units of the optional distance cost attribute.

  • MilesThe distance units will be miles. This is the default.
  • KilometersThe distance units will be kilometers.
  • FeetThe distance units will be feet.
  • YardsThe distance units will be yards.
  • MetersThe distance units will be meters.
  • InchesThe distance units will be inches.
  • CentimetersThe distance units will be centimeters.
  • MillimetersThe distance units will be millimeters.
  • DecimetersThe distance units will be decimeters.
  • NauticalMilesThe distance units will be nautical miles.

Caution:
The Inches, Centimeters, Millimeters, and Decimeters options are not available when the network data source is a service.

String
earliest_route_start_date
(Optional)

The default earliest start date for routes. This date is used for all routes for which the EarliestStartDate field in the Routes sublayer is null. When no parameter value is specified, all rows in the Routes sublayer must specify a value in the EarliestStartDate field.

Specify this parameter value using a datetime.date object.

Caution:
Although the other Network Analyst solvers allow you to use special dates to model a day of the week or the current date instead of a specific, static date, the last mile delivery solver does not. You must choose a specific date.

Date
earliest_route_start_time
(Optional)

The default earliest start time for routes. This time of day is used for all routes for which the EarliestStartTime field in the Routes sublayer is null. When no parameter value is specified, all rows in the Routes sublayer must specify a value in the EarliestStartTime field.

Specify this parameter value using a datetime.time object.

Date
max_route_total_time
(Optional)

The maximum allowed total time for each route. The value can be any positive number.

The value is used for all routes for which the MaxTotalTime field in the Routes sublayer is null. When no parameter value is specified, all rows in the Routes sublayer must specify a value in the MaxTotalTime field.

The value is interpreted in the units specified in the time_units parameter.

Double
time_zone_for_time_fields
(Optional)

Specifies the time zone that will be used for the input date-time fields supported by the tool.

  • LOCAL_TIME_AT_LOCATIONS The date-time values associated with the orders or depots will be in the time zone in which the orders and depots are located. For routes, the date-time values are based on the time zone in which the starting depot for the route is located. If a route does not have a starting depot, all orders and depots across all the routes must be in a single time zone. This is the default.
  • UTCThe date-time values associated with the orders, depots, and routes will be in coordinated universal time (UTC) and are not based on the time zone in which the orders or depots are located.

Specifying the date-time values in UTC is useful if you do not know the time zone in which the orders or depots are located or when you have orders and depots in multiple time zones and you want all the date-time values to start simultaneously.

String
sequence_gap
(Optional)

The gap in numerical values to leave in the Sequence field in the Orders sublayer between adjacent orders when the analysis is solved. The value acts as a multiplier for the actual sequence of orders on each route. For example, if the gap is 5, the first order on the route will have a Sequence field value of 5, the second order on the route will have a Sequence field value of 10, the third 15, and so on. This parameter helps support inserting orders after the initial route plan has been created because the new orders can be inserted into the sequence gaps.

The value must be a positive integer. The default is 1.

The first time the analysis is solved, the Sequence field values will be populated with sequential values using the designated sequence gap. On subsequent solves of the same analysis, the Sequence field values of existing orders will be maintained, and new orders will be inserted into the gaps using available integer values for the Sequence field that are not in use by other orders. If the sequence gap is set to 1, the sequence values will always be updated to contiguous values for every solve.

Long
ignore_invalid_order_locations
(Optional)

Specifies whether invalid order locations will be ignored.

  • SKIPInvalid order locations will be ignored so that the analysis will succeed using only valid locations.
  • HALTInvalid order locations will not be ignored and will cause the analysis to fail. This is the default.
Boolean
line_shape
(Optional)

Specifies the shape type that will be used for the route features that are output by the analysis.

  • ALONG_NETWORKThe output routes will have the exact shape of the underlying network sources. The output includes route measurements for linear referencing. The measurements increase from the first stop and record the cumulative impedance to reach a given position.
  • NO_LINESNo shape will be generated for the output routes.
  • STRAIGHT_LINESThe output route shape will be a single straight line between the stops. This is the default.

Regardless of the output shape type specified, 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
generate_directions_on_solve
(Optional)

Specifies whether directions will be generated when the analysis is solved.

  • DIRECTIONSTurn-by-turn directions will be generated on solve.
  • NO_DIRECTIONSTurn-by-turn directions will not be generated on solve. This is the default.
Boolean

Derived Output

NameExplanationData Type
out_network_analysis_layer

The new network analysis layer.

Network Analyst Layer

Code sample

MakeLastMileDeliveryAnalysisLayer example 1 (Python window)

Run the tool specifying a subset of parameters.

import datetime

arcpy.na.MakeLastMileDeliveryAnalysisLayer(
    r"C:\Data\SanFrancisco.gdb\Transportation\Streets_ND",
    "Package Delivery",
    "Trucking Time",
    time_units="Hours",
    earliest_route_start_date=datetime.date(2023, 11, 28),
    earliest_route_start_time=datetime.time(7, 30, 0),
    route_start_flexibility=1.5,
    line_shape="NO_LINES"
)

Environments

Licensing information

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

Related topics