Create Routes (Linear Referencing)

Summary

Creates routes from existing lines. The input line features that share a common identifier are merged to create a single route.

Usage

  • The unique values in the Route Identifier Field are written to Output Route Feature Class.

  • Use the Make Feature Layer or Make Query Table tools to effectively reduce the number of lines that will be used to create routes.

  • If the Output Route Feature Class will be written to a geodatabase, an appropriate M Tolerance, M Resolution, and M Domain environment should be set.

  • Use a Measure Factor to convert between route measure units. For example, to convert from feet to miles, use a factor of 0.00018939394.

  • Use a Measure Offset in applications where the start measure of each route needs to be a value other than 0.

  • The Ignore spatial gaps parameter is not used when the Values from two fields Measure Source option has been specified. This is because measure values are dictated by the From-Measure Field and To-Measure Field values.

  • When the Length of features or Values from a single field Measure Source option is used, the Coordinate Priority is determined by placing the minimum bounding rectangle around the input features that will be merged to create one route.

  • When the Values from two fields Measure Source option is used, it is not necessary to specify a coordinate priority because measure direction is implied by the values in the From-Measure Field and the To-Measure Field.

  • An attribute index on the route identifier field speeds up the dynamic segmentation process. If you will be using the Output Route Feature Class for dynamic segmentation, it is recommended that you choose to have an attribute index created.

  • If any features are rejected by the Create Routes tool, a text file is created in the temporary file path to store information about those features. For example, C:\Users\patrickb\AppData\Local\Temp\Create_Output0.txt (where Create_Output is the name of the output route feature class).

  • The Output has M Values environment setting will be ignored. The Output Route Feature Class will have M (measure) values.

Parameters

LabelExplanationData Type
Input Line Features

The features from which routes will be created.

Feature Layer
Route Identifier Field

The field containing values that uniquely identify each route.

Field
Output Route Feature Class

The feature class to be created. It can be a shapefile or a geodatabase feature class.

Feature Class
Measure Source

Specifies how route measures will be obtained.

  • Length of features — The geometric length of the input features will be used to accumulate the measures. This is the default.
  • Values from a single field — The value stored in a single field will be used to accumulate the measures.
  • Values from two fields — The values stored in both from- and to- measure fields will be used to set the measures.
String
From-Measure Field
(Optional)

A field containing measure values. This field must be numeric and is required when the measure source is Values from a single field or Values from two fields.

Field
To-Measure Field
(Optional)

A field containing measure values. This field must be numeric and is required when the measure source is Values from two fields.

Field
Coordinate Priority
(Optional)

The position from which measures will be accumulated for each output route. This parameter is ignored when the measure source is Values from two fields.

  • Upper left corner — Measures will be accumulated from the point closest to the minimum bounding rectangle's upper left corner. This is the default.
  • Lower left corner — Measures will be accumulated from the point closest to the minimum bounding rectangle's lower left corner.
  • Upper right corner — Measures will be accumulated from the point closest to the minimum bounding rectangle's upper right corner.
  • Lower right corner — Measures will be accumulated from the point closest to the minimum bounding rectangle's lower right corner.
String
Measure Factor
(Optional)

A value multiplied by the measure length of each input line before they are merged to create route measures. The default is 1.

Double
Measure Offset
(Optional)

A value added to the route measures after the input lines have been merged to create a route. The default is 0.

Double
Ignore spatial gaps
(Optional)

Specifies whether spatial gaps will be ignored when calculating the measures on disjointed routes. This parameter is applicable when the measure source is Length of features or Values from a single field.

  • Checked—Spatial gaps will be ignored. Measure values will be continuous for disjointed routes. This is the default.
  • Unchecked—Do not ignore spatial gaps. The measure values on disjointed routes will have gaps. The gap distance is calculated using the straight-line distance between the endpoints of the disjointed parts.
Boolean
Build index
(Optional)

Specifies whether an attribute index will be created for the route identifier field that is written to the output route feature class.

  • Checked—Create an attribute index. This is the default.
  • Unchecked—Do not create an attribute index.
Boolean

arcpy.lr.CreateRoutes(in_line_features, route_id_field, out_feature_class, measure_source, {from_measure_field}, {to_measure_field}, {coordinate_priority}, {measure_factor}, {measure_offset}, {ignore_gaps}, {build_index})
NameExplanationData Type
in_line_features

The features from which routes will be created.

Feature Layer
route_id_field

The field containing values that uniquely identify each route.

Field
out_feature_class

The feature class to be created. It can be a shapefile or a geodatabase feature class.

Feature Class
measure_source

Specifies how route measures will be obtained.

  • LENGTHThe geometric length of the input features will be used to accumulate the measures. This is the default.
  • ONE_FIELDThe value stored in a single field will be used to accumulate the measures.
  • TWO_FIELDSThe values stored in both from- and to- measure fields will be used to set the measures.
String
from_measure_field
(Optional)

A field containing measure values. This field must be numeric and is required when the measure source is ONE_FIELD or TWO_FIELDS.

Field
to_measure_field
(Optional)

A field containing measure values. This field must be numeric and is required when the measure source is TWO_FIELDS.

Field
coordinate_priority
(Optional)

The position from which measures will be accumulated for each output route. This parameter is ignored when the measure source is TWO_FIELDS.

  • UPPER_LEFTMeasures will be accumulated from the point closest to the minimum bounding rectangle's upper left corner. This is the default.
  • LOWER_LEFTMeasures will be accumulated from the point closest to the minimum bounding rectangle's lower left corner.
  • UPPER_RIGHTMeasures will be accumulated from the point closest to the minimum bounding rectangle's upper right corner.
  • LOWER_RIGHTMeasures will be accumulated from the point closest to the minimum bounding rectangle's lower right corner.
String
measure_factor
(Optional)

A value multiplied by the measure length of each input line before they are merged to create route measures. The default is 1.

Double
measure_offset
(Optional)

A value added to the route measures after the input lines have been merged to create a route. The default is 0.

Double
ignore_gaps
(Optional)

Specifies whether spatial gaps will be ignored when calculating the measures on disjointed routes. This parameter is applicable when the measure source is LENGTH or ONE_FIELD.

  • IGNORESpatial gaps will be ignored. Measure values will be continuous for disjointed routes. This is the default.
  • NO_IGNOREDo not ignore spatial gaps. The measure values on disjointed routes will have gaps. The gap distance is calculated using the straight-line distance between the endpoints of the disjointed parts.
Boolean
build_index
(Optional)

Specifies whether an attribute index will be created for the route identifier field that is written to the output route feature class.

  • INDEXCreate an attribute index. This is the default.
  • NO_INDEXDo not create an attribute index.
Boolean

Code sample

CreateRoutes example 1 (Python window)

The following Python window script demonstrates how to use the CreateRoutes function in the Python window.

import arcpy
arcpy.env.workspace = "C:/Data"
arcpy.CreateRoutes_lr(base_roads.shp, "route1", "newRoutes", "LENGTH", "#", "#", 
                      "LOWER_LEFT", 0.00018939394)
CreateRoutes example 2 (stand-alone script)

The following Python script demonstrates how to use the CreateRoutes function using shapefile data in a stand-alone Python script.

# Name CreateRoutes_Example2.py
# Description: Create routes from lines. The lines are in a shapefile workspace.
# The LENGTH option will be used to set the measures, and a measure factor
# will be used to convert measure units from feet to miles.

# Import system modules
import arcpy

# Set workspace
arcpy.env.workspace = "C:/Data"

# Set local variables
in_lines = "base_roads.shp"
rid = "route1" 
out_routes = "create_output1" 

# Execute CreateRoutes
arcpy.CreateRoutes_lr(in_lines, rid, out_routes, "LENGTH", "#", "#", 
                      "LOWER_LEFT", 0.00018939394)
CreateRoutes example 3 (stand-alone script)

The following Python script demonstrates how to use the CreateRoutes function using file geodatabase data in a stand-alone Python script.

# Name CreateRoutes_Example3.py
# Description: Create routes from lines. The lines are in a file geodatabase.
# The ONE_FIELD option will be used to set the measures.

# Import system modules 
import arcpy

# Set workspace
arcpy.env.workspace = "C:/Data/pitt.gdb"

# Set local variables
in_lines = "roads/base_roads"  # base_roads exists in the roads feature dataset
rid = "route1"
m_fld = "len_mile"
out_routes = "roads/create_output2"  # write result to the roads feature dataset

# Execute CreateRoutes
arcpy.CreateRoutes_lr(in_lines, rid, out_routes, "ONE_FIELD", m_fld, "#", 
                      "LOWER_LEFT")
CreateRoutes example 4 (stand-alone script)

The following Python script demonstrates how to use the CreateRoutes function in a stand-alone Python script using enterprise geodatabase data.

# Name CreateRoutes_Example4.py
# Description:  Create routes from lines. The lines are in an enterprise 
# geodatabase. The TWO_FIELD option will be used to set the measures.

# Import system modules
import arcpy

# Set workspace
arcpy.env.workspace = "C:/MyProject/myConn.sde"

# Set local variables
# base_roads is a standalone feature class
in_lines = arcpy.ValidateTableName("base_roads", wkspc)
rid = "route1"
fr_fld = "begmp1"
to_fld = "endmp1" 
out_routes = "create_output3"  # write the result to a standalone feature class

# Execute CreateRoutes
arcpy.CreateRoutes_lr(in_lines, rid, out_routes, "TWO_FIELDS", fr_fld, to_fld)

Licensing information

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

Related topics