Summary
Finding a route analysis can mean determining the quickest or shortest way to travel between locations. You might want to use this tool to generate driving directions to visit multiple stops or to measure the distance or travel time between locations. The tool is capable of finding routes for one or more vehicles each time it runs, so you can determine the best routes for several drivers to visit preassigned stops, for instance, or measure in a single solve the distance of home-to-work trips for many commuters.
Illustration
Usage
- To find routes for multiple vehicles, see the RouteName attribute, which is described in the Stops parameter. Finding routes for many vehicles requires the set of stops to be grouped into smaller subsets—one for each route, or vehicle—before solving. A route is generated for each subset of stops. (Use the vehicle routing problem tools instead if you want the grouping of the stops, as well as the routing between the stops, to be optimized for you.)
The tool dialog box groups the various optional parameters into the following six categories to make it easier for you to manage them:
- Advanced Analysis
- Barriers
- Custom Travel Mode
- Network Dataset
- Network Locations
- Output
- Service Capabilities
Syntax
FindRoutes(Stops, Measurement_Units, Network_Dataset, Output_Geodatabase, Output_Routes_Name, Output_Route_Edges_Name, Output_Directions_Name, Output_Stops_Name, {Reorder_Stops_to_Find_Optimal_Routes}, {Preserve_Terminal_Stops}, {Return_to_Start}, {Use_Time_Windows}, {Time_of_Day}, {Time_Zone_for_Time_of_Day}, {UTurn_Policy}, {Point_Barriers}, {Line_Barriers}, {Polygon_Barriers}, {Time_Attribute}, {Time_Attribute_Units}, {Distance_Attribute}, {Distance_Attribute_Units}, {Use_Hierarchy_in_Analysis}, {Restrictions}, {Attribute_Parameter_Values}, {Accumulate_Attributes}, {Maximum_Snap_Tolerance}, {Feature_Locator_WHERE_Clause}, {Route_Shape}, {Route_Line_Simplification_Tolerance}, {Populate_Route_Edges}, {Populate_Directions}, {Directions_Language}, {Directions_Distance_Units}, {Directions_Style_Name}, {Maximum_Features_Affected_by_Point_Barriers}, {Maximum_Features_Affected_by_Line_Barriers}, {Maximum_Features_Affected_by_Polygon_Barriers}, {Maximum_Stops}, {Maximum_Stops_per_Route}, {Force_Hierarchy_Beyond_Distance}, {Save_Output_Network_Analysis_Layer}, {Travel_Mode}, {Time_Zone_for_Time_Windows}, {Overrides}, {Save_Route_Data})
Parameter | Explanation | Data Type |
Stops | This tool routes between the stops specified in this parameter. A minimum of two stops are necessary to solve an analysis. When specifying the stops, you can set properties for each one, such as its name or service time, by using attributes. The stops can be specified with the following attributes: OBJECTID—The system-managed ID field. SHAPE—The geometry field indicating the geographic location of the incident. Name—The name of the stop. The name is used in the driving directions. If the name is not specified, a unique name prefixed with Location is automatically generated in the output stops, routes, and directions. RouteName—The name of the route to which the stop is assigned. Assigning the same route name to different stops causes those stops to be grouped together and visited by the same route. You can generate many routes in a single solve by assigning unique route names to different groups of stops. With this tool you can group up to 150 stops into one route. Sequence—The output routes will visit the stops in the order you specify with this attribute. Within a group of stops that have the same route name value, the sequence number should be greater than 0 but not greater than the total number of stops. Also, the sequence number should not be duplicated. If Reorder Stops To Find Optimal Routes is checked (True), all but possibly the first and last sequence values for each route name are ignored so the tool can find the sequence that minimizes overall travel for each route. (The settings for Preserve Ordering of Stops and Return to Start determine whether the first or last sequence values for each route are ignored.) AdditionalTime—The amount of time spent at the stop, which is added to the total time of the route. The units for this attribute value are specified by the Measurement Units parameter. The attribute value is included in the analysis only when the measurement units are time based. The default value is 0. Generally, the location of a stop, such as a home, isn't exactly on the street; it is set back somewhat from the road. This attribute value can be used to model the distance between the actual stop location and its location on the street, if it is important to include that distance in the total travel distance. AdditionalDistance—The extra distance traveled at the stops, which is added to the total distance of the route. The units for this attribute value are specified by the Measurement Units parameter. The attribute value is included in the analysis only when the measurement units are distance based. The default value is 0. Generally, the location of a stop, such as a home, isn't exactly on the street; it is set back somewhat from the road. This attribute value can be used to model the distance between the actual stop location and its location on the street, if it is important to include that distance in the total travel distance. TimeWindowStart—The earliest time the stop can be visited. Make sure you specify the value as a date and time value, such as 8/12/2015 12:15 PM. By specifying a start and end time for a stop's time window, you are defining when a route should visit the stop. As long as Use Time Windows is checked and you've chosen a time-based unit for Measurement Units, the tool will try to find a solution that minimizes overall travel and reaches the stop within the prescribed time window. When solving a problem that spans multiple time zones, time-window values refer to the time zone in which the stop is located. This field can contain a null value; a null value indicates a route can arrive at any time before the time indicated in the TimeWindowEnd attribute. If a null value is also present in TimeWindowEnd, a route can visit the stop at any time. TimeWindowEnd—The latest time the stop can be visited. Make sure you specify the value as a date and time value, such as 8/12/2015 12:15 PM. By specifying a start and end time for a stop's time window, you are defining when a route should visit the stop. As long as Use Time Windows is checked and you've chosen a time-based unit for Measurement Units, the tool will try to find a solution that minimizes overall travel and reaches the stop within the prescribed time window. When solving a problem that spans multiple time zones, time-window values refer to the time zone in which the stop is located. This field can contain a null value; a null value indicates a route can arrive at any time after the time indicated in the TimeWindowStart attribute. If a null value is also present in TimeWindowStart, a route can visit the stop at any time. CurbApproach—Specifies the direction a vehicle may arrive at and depart from the stop. The field value is specified as one of the following integers (use the numeric code, not the name in parentheses):
The CurbApproach property is designed to work with both kinds of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider a stop on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach a stop from one of two directions, that is, so it ends up on the right or left side of the vehicle. For example, if you want to arrive at a stop and not have a lane of traffic between the vehicle and the stop, you would choose Right side of vehicle (1) in the United States but Left side of vehicle (2) in the United Kingdom. | Feature Set |
Measurement_Units | Specify the units that should be used to measure and report the total travel time or travel distance for the output routes. The units you choose for this parameter determine whether the tool will measure distance or time to find the best routes. Choose a time unit to minimize travel time for your chosen travel mode (driving or walking time, for instance). To minimize travel distance for the given travel mode, choose a distance unit. Your choice also determines in which units the tool will report total time or distance in the results. The choices include the following:
The tool chooses whether to use the network cost attribute specified in the Time Attribute or Distance Attribute parameter depending on whether the chosen measurement units are time or distance based. The tool performs the necessary unit conversion when the Measurement Units value differs from the units of the corresponding time or distance cost attribute. | String |
Network_Dataset | The network dataset on which the analysis will be performed. Network datasets most often represent street networks but may represent other kinds of transportation networks as well. The network dataset needs at least one time-based and one distance-based cost attribute. | Network Dataset Layer |
Output_Geodatabase | The output workspace. This workspace must already exist. The default output workspace is in_memory. | Workspace |
Output_Routes_Name | The name of the output feature class containing routes or the lines that connect stops. This feature class also contains, as an attribute, the total travel time or distance. Output from Find Routes describes the schema of this output feature class. | String |
Output_Route_Edges_Name | The name of the output feature class containing the route edges. Route edges represent the individual street features that are traversed by a route. Output from Find Routes describes the schema of this output feature class. | String |
Output_Directions_Name | The name of the output feature class containing directions. Output from Find Routes describes the schema of this output feature class. | String |
Output_Stops_Name | The name of the output feature class containing the output stops. Output from Find Routes describes the schema of this output feature class. | String |
Reorder_Stops_to_Find_Optimal_Routes (Optional) | Specify whether to visit the stops in the order you define or the order the tool determines will minimize overall travel.
Finding the optimal stop order and the best routes is commonly known as solving the traveling salesman problem (TSP). | Boolean |
Preserve_Terminal_Stops (Optional) |
When Reorder Stops to Find Optimal Routes is checked (or True), you have options to preserve the starting or ending stops and the tool can reorder the rest. The first and last stops are determined by their Sequence attribute values or, if the Sequence values are null, by their Object ID values.
Preserve Terminal Stops is ignored when Reorder Stops to Find Optimal Routes is unchecked (or False). | String |
Return_to_Start (Optional) | Choose whether routes should start and end at the same location. With this option you can avoid duplicating the first stop feature and sequencing the duplicate stop at the end. The starting location of the route is the stop feature with the lowest value in the Sequence attribute. If the Sequence values are null, it is the stop feature with the lowest Object ID value.
| Boolean |
Use_Time_Windows (Optional) | Check this option (or set it to True) if any input stops have time windows that specify when the route should reach the stop. You can add time windows to input stops by entering time values in the TimeWindowStart and TimeWindowEnd attributes.
The tool will take slightly longer to run when Use Time Windows is checked (or True), even when none of the input stops have time windows, so it is recommended to uncheck this option (set to False) if possible. | Boolean |
Time_of_Day (Optional) |
Specifies the time and date at which the routes should begin. If your network dataset contains live or historical traffic data, specifying a time-of-day results in a more accurate estimation of travel time between stops because the travel times account for the traffic conditions that are applicable for that date and time. The Time Zone for Time of Day parameter specifies whether this time and date refer to UTC or the time zone in which the stop is located. The tool ignores this parameter when Measurement Units isn't set to a time-based unit. | Date |
Time_Zone_for_Time_of_Day (Optional) |
Specifies the time zone of the Time of Day parameter.
| 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, or streets, 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.
The value of this parameter is overridden when Travel Mode (Travel_Mode in Python) is set to any value other than custom. | String |
Point_Barriers (Optional) | Specifies point barriers, which are split into two types: restriction and added cost point barriers. They temporarily restrict traversal across or add impedance to points on the network. The point barriers are defined by a feature set, and the attribute values you specify for the point features determine whether they are restriction or added cost barriers. The fields in the attribute table are listed and described below. ObjectID: The system-managed ID field. Shape: The geometry field indicating the geographic location of the network analysis object. Name: The name of the barrier. BarrierType: Specifies whether the barrier restricts travel completely or adds cost when traveling through it. There are two options:
Use the value 0 for Restriction and 2 for Added Cost. Additional_Time: Indicates how much travel time is added when the barrier is traversed. This field is applicable only for added-cost barriers and only if the measurement units are time based. This field value must be greater than or equal to zero, and its units are the same as those specified in the Measurement Units parameter. Additional_Distance: Indicates how much distance is added when the barrier is traversed. This field is applicable only for added-cost barriers and only if the measurement units are distance based. The field value must be greater than or equal to zero, and its units are the same as those specified in the Measurement Units parameter. | Feature Set |
Line_Barriers (Optional) |
Specifies line barriers, which temporarily restrict traversal across them. The line barriers are defined by a feature set. The fields in the attribute table are listed and described below. ObjectID: The system-managed ID field. Shape: The geometry field indicating the geographic location of the network analysis object. Name: The name of the barrier. | Feature Set |
Polygon_Barriers (Optional) | Specifies polygon barriers, which are split into two types: restriction and scaled cost polygon barriers. They temporarily restrict traversal or scale impedance on the parts of the network they cover. The polygon barriers are defined by a feature set, and the attribute values you specify for the polygon features determine whether they are restriction or scaled cost barriers. The fields in the attribute table are listed and described below. ObjectID: The system-managed ID field. Shape: The geometry field indicating the geographic location of the network analysis object. Name: The name of the barrier. BarrierType: Specifies whether the barrier restricts travel completely or scales the cost of traveling through it. There are two options:
Use the value 0 for Restriction and 1 for Scaled Cost. ScaledTimeFactor: This is the factor by which the travel time of the streets intersected by the barrier is multiplied. This field is applicable only for scaled-cost barriers and only if the measurement units are time based. The field value must be greater than zero. ScaledDistanceFactor: This is the factor by which the distance of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers and only if the measurement units are distance based. The attribute value must be greater than zero. | Feature Set |
Time_Attribute (Optional) | Defines the network cost attribute to use when the measurement units value is a time unit. The tool performs the necessary time-unit conversion when the measurement units value differs from the units of the cost attribute defined here. In other words, the time units of the default cutoff and the network cost attribute don't need to be the same. The value of this parameter is overridden when Travel Mode (Travel_Mode in Python) is set to any value other than Custom. | String |
Time_Attribute_Units (Optional) | The units of the time attribute. You can explicitly set the time attribute units, but it is recommended to pass nothing or "#" and let the solver determine the units. The value of this parameter is overridden when Travel_Mode is set to any value other than CUSTOM. | String |
Distance_Attribute (Optional) | Defines the network cost attribute to use when the measurement units value is a distance unit. The tool performs the necessary distance-unit conversion when the measurement units value differs from the units of the cost attribute defined here. In other words, the measurement units and the distance units of the network cost attribute don't need to be the same. The value of this parameter is overridden when Travel Mode (Travel_Mode in Python) is set to any value other than Custom. | String |
Distance_Attribute_Units (Optional) | The units of the distance attribute. You can explicitly set the distance attribute units, but it is recommended to pass nothing or "#" and let the solver determine the units. The value of this parameter is overridden when Travel_Mode is set to any value other than CUSTOM. | String |
Use_Hierarchy_in_Analysis (Optional) | Specify whether hierarchy should be used when finding the shortest routes between points.
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. You can use the Force_Hierarchy_Beyond_Distance parameter to force the solve to use hierarchy even if Use_Hierarchy_in_Analysis is set to False. This parameter is ignored unless Travel_Mode is set to CUSTOM. When modeling a custom walking mode, it is recommended to turn off hierarchy since the hierarchy is designed for motorized vehicles. | Boolean |
Restrictions [restriction,...] (Optional) | Indicates which network restriction attributes are respected during solve time. The value of this parameter is overridden when Travel Mode (Travel_Mode in Python) is set to any value other than custom. | String |
Attribute_Parameter_Values (Optional) | Specifies the parameter values for network attributes that have parameters. The record set has two columns that work together to uniquely identify parameters and another column that specifies the parameter value. The value of this parameter is overridden when Travel Mode (Travel_Mode in Python) is set to any value other than custom. The attribute parameter values record set has associated attributes. The fields in the attribute table are listed below and described. ObjectID: The system-managed ID field. AttributeName: The name of the network attribute whose attribute parameter is set by the table row. ParameterName: The name of the attribute parameter whose value is set by the table row. (Object type parameters cannot be updated using this tool.) ParameterValue: The value you want for the attribute parameter. If a value is not specified, the attribute parameter is set to null. | Record Set |
Accumulate_Attributes [attribute,...] (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 Time Attribute (Time_Attribute in Python) or Distance Attribute (Distance_Attribute in Python) parameter to calculate the shortest paths. For each cost attribute that is accumulated, a Total_[attribute] field is added to the routes that are output by the solver. | String |
Maximum_Snap_Tolerance (Optional) | The maximum snap tolerance is the furthest distance that Network Analyst searches when locating or relocating a point onto the network. The search looks for suitable edges or junctions and snaps the point to the nearest one. If a suitable location isn't found within the maximum snap tolerance, the object is marked as unlocated. | Linear Unit |
Feature_Locator_WHERE_Clause (Optional) | A SQL expression used to select a subset of source features that limits on which network elements stops can be located. The syntax for this parameter consists of two parts: the first is the source feature class name (followed by a space) and the second is the SQL expression. To write a SQL expression for two or more source feature classes, separate them with a semicolon. To ensure facilities are not located on limited-access highways, for example, write a SQL expression like the following to exclude those source features: "Streets" "FUNC_CLASS not in('1', '2')". Note that barriers ignore the feature locator WHERE clause when loading. | String |
Route_Shape (Optional) | Specify the type of route features that are output by the tool. The parameter can be specified using one of the following values:
When the Route Shape parameter is set to True Shape, the generalization of the route shape can be further controlled using the appropriate value for the Route Line Simplification Toleranceparameter. No matter which value you choose for the Route Shapeparameter, the best route is always determined by minimizing the travel time or the travel distance, never using the straight-line distance between stops. This means that only the route shapes are different, not the underlying streets that are searched when finding the route. | String |
Route_Line_Simplification_Tolerance (Optional) | Specify by how much you want to simplify the route geometry. The tool ignores this parameter if the Route_Shape parameter isn't set to TRUE_LINES_WITH_MEASURES or TRUE_LINES_WITHOUT_MEASURES. Simplification maintains critical points on a route, such as turns at intersections, to define the essential shape of the route and removes other points. The simplification distance you specify is the maximum allowable offset that the simplified line can deviate from the original line. Simplifying a line reduces the number of vertices that are part of the route geometry. This improves the tool execution time. The value of this parameter is overridden when Travel Mode (Travel_Mode in Python) is set to any value other than custom. | Linear Unit |
Populate_Route_Edges (Optional) |
Specify whether the tool should generate edges for each route. Route edges represent the individual street features or other similar features that are traversed by a route. The output Route Edges layer is commonly used to see which streets or paths are traveled on the most or least by the resultant routes.
| Boolean |
Populate_Directions (Optional) | Specify whether the tool should generate driving directions for each route.
| Boolean |
Directions_Language (Optional) | Specify the language that should be used when generating driving directions. This parameter is used only when the Populate Directions parameter is checked, or set to True. The directions languages that are available depend on what ArcGIS language packs you have installed on your computer. The values are entered in two- or five-character language codes, for example, en for English or zh-CN for simplified Chinese. If an unsupported language code is specified, the tool returns the directions using the default language, English. | String |
Directions_Distance_Units (Optional) | Specify the units for displaying travel distance in the driving directions. This parameter is used only when the Populate Directions parameter is checked, or set to True.
| String |
Directions_Style_Name (Optional) | Specify the name of the formatting style for the directions. This parameter is used only when the Populate Directions parameter is checked, or set to True. The parameter can be specified using the following values:
| String |
Maximum_Features_Affected_by_Point_Barriers (Optional) | Limits how many features can be affected by point barriers. This parameter helps you govern the amount of processing that occurs when solving. For example, you could assign a low value to this parameter for a free version of the service you are creating and use a higher value for a paid-subscription version of the service. A null value indicates there is no limit. | Long |
Maximum_Features_Affected_by_Line_Barriers (Optional) |
Limits how many features can be affected by line barriers. This parameter helps you govern the amount of processing that occurs when solving. For example, you could assign a low value to this parameter for a free version of the service you are creating and use a higher value for a paid-subscription version of the service. A null value indicates there is no limit. | Long |
Maximum_Features_Affected_by_Polygon_Barriers (Optional) |
Limits how many features can be affected by polygon barriers. This parameter helps you govern the amount of processing that occurs when solving. For example, you could assign a low value to this parameter for a free version of the service you are creating and use a higher value for a paid-subscription version of the service. A null value indicates there is no limit. | Long |
Maximum_Stops (Optional) | Limits how many stops can be added to the route analysis. This parameter is related to the Stops parameter. This parameter helps you govern the amount of processing that occurs when solving. For example, you could assign a low value to this parameter for a free version of the service you are creating and use a higher value for a paid-subscription version of the service. A null value indicates there is no limit. | Long |
Maximum_Stops_per_Route (Optional) | Limits the maximum number of stops that can be assigned to each route in an analysis. Stops are preassigned to routes using the RouteName field of points in the Stops parameter. This parameter helps you govern the amount of processing that occurs when solving. For example, you could assign a low value to this parameter for a free version of the service you are creating and use a higher value for a paid-subscription version of the service. A null value indicates there is no limit. | Long |
Force_Hierarchy_Beyond_Distance (Optional) | Specifies the distance after which the solver will force hierarchy when finding routes, even if hierarchy is not enabled. The units of this parameter are the same as those shown in the Distance Attribute Units parameter. Finding routes between stops that are far away while using the network's hierarchy tends to incur much less processing than finding the same routes without using the hierarchy. This parameter helps you govern the amount of processing that occurs when solving. A null value indicates that the hierarchy will never be enforced and the value of the Use Hierarchy in Analysis parameter will always be honored. If the input network dataset does not support hierarchy, specifying a value for this parameter will result in an error. A null value should be used in this case. This parameter is disabled unless the network dataset includes a hierarchy attribute. | Double |
Save_Output_Network_Analysis_Layer (Optional) |
In either case, feature classes containing the results are returned. However, a server administrator may want to choose to output a network analysis layer as well so the setup and results of the tool can be debugged using the Network Analyst controls in the ArcGIS Desktop environment. This can make the debugging process much easier. In ArcGIS Desktop, the default output location for the network analysis layer is in the scratch folder. You can determine the location of the scratch folder by evaluating the value of arcpy.env.scratchFolder geoprocessing environment. The output network analysis layer is stored as an LYR file whose name begins with _ags_gpna and is followed by an alphanumeric GUID. | Boolean |
Travel_Mode (Optional) | Choose the mode of transportation for the analysis. CUSTOM is always a choice. For other travel mode names to appear, they must be present in the network dataset specified in the Network_Dataset parameter. (The arcpy.na.GetTravelModes function provides a dictionary of the travel mode objects configured on a network dataset, and the name property returns the name of a travel mode object.) A travel mode is defined on a network dataset and provides override values for parameters that, together, model car, truck, pedestrian, or other modes of travel. By choosing a travel mode here, you don't need to provide values for the following parameters, which are overridden by values specified in the network dataset:
| String |
Time_Zone_for_Time_Windows (Optional) | Specifies the time zone for the time window values on stops. The time windows are specified as part of TimeWindowStart and TimeWindowEnd fields on stops. This parameter is applicable only when the Use Time Windows parameter is checked (or set to True).
| String |
Overrides (Optional) | Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems. The value for this parameter needs to be specified in JavaScript Object Notation (JSON). For example, a valid value is of the following form {"overrideSetting1" : "value1", "overrideSetting2" : "value2"}. The override setting name is always enclosed in double quotation marks. The values can be a number, Boolean, or a string. The default value for this parameter is no value, which indicates not to override any solver settings. Overrides are advanced settings that should be used only after careful analysis of the results obtained before and after applying the settings. A list of supported override settings for each solver and their acceptable values can be obtained by contacting Esri Technical Support. | String |
Save_Route_Data (Optional) | Choose whether the output includes a zip file that contains a file geodatabase holding the inputs and outputs of the analysis in a format that can be used to share route layers with ArcGIS Online or Portal for ArcGIS. In ArcGIS Desktop, the default output location for this output file is in the scratch folder. You can determine the location of the scratch folder by evaluating the value of the arcpy.env.scratchFolder geoprocessing environment.
| Boolean |
Derived Output
Name | Explanation | Data Type |
Solve_Succeeded | Determines if the service was able to find routes successfully. | Boolean |
Output_Routes | The resulting route or routes between the stops. | Feature Set |
Output_Route_Edges | The individual road segments that the routes travel along. | Feature Set |
Output_Directions | Turn-by-turn driving directions for each resulting route between the stops. The parameter includes the driving directions as well as the geometry for the directions feature corresponding to the text. | Feature Set |
Output_Stops | The attributes of the stop or stops visited by the route as well as stops that could not be reached by any of the routes. | Feature Set |
Output_Network Analysis_Layer | Network analysis layer with properties as configured in the tool parameters that can be used for further analysis or debugging in the map. | File |
Output_Route_Data | A zip file containing all the information for a particular route. | File |
Code sample
FindRoutes example 1 (Python window)
Execute the tool using the required parameters.
stops = arcpy.FeatureSet()
stops.load("Stops")
arcpy.na.FindRoutes(stops, "Miles", "Streets_ND", "in_memory", "Routes",
"RouteEdges", "Directions", "OutStops",
UTurn_Policy="NO_UTURNS")
FindRoutes example 2 (stand-alone script)
The following stand-alone Python script demonstrates how to use the FindRoutes tool.
# Name: FindRoutes_Workflow.py
# Description: Find the fastest route visting all the stops. The output will
# show the route, driving directions, and how long it took to get
# to each stop.
# 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 = r'C:\arcgis\ArcTutor\Network Analyst\Tutorial\SanDiego.gdb'
env.overwriteOutput = True
#Set local variables
inNetworkDataset = r'Transportation\Streets_ND'
inStops = r'Analysis\Stops'
outGeodatabase = r'C:\arcgis\ArcTutor\Network Analyst\Tutorial\Output.gdb'
outRoutes = "Routes"
outRouteEdges = "RouteEdges"
outDirections = "Directions"
outStops = "Stops"
measurement_units = "Minutes"
# Run FindRoutes. Reorder the stops to find the fastest route, but maintain
# the first stop as the starting point and the last stop as the end point.
arcpy.na.FindRoutes(inStops, measurement_units, inNetworkDataset,
outGeodatabase, outRoutes, outRouteEdges, outDirections,
outStops, Reorder_Stops_to_Find_Optimal_Routes=True,
Preserve_Terminal_Stops="PRESERVE_BOTH")
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 occured on line %i" % tb.tb_lineno
print str(e)
Environments
Licensing information
- Basic: Requires Network Analyst
- Standard: Requires Network Analyst
- Advanced: Requires Network Analyst