Append Routes (Location Referencing)

Title  Append Routes (Location Referencing)

Summary

Appends routes from an input polyline into an LRS Network.

When the target layer is a feature service layer, the validation results for this tool are written to the ArcGIS Server directory. This file is automatically cleaned up in 10 minutes by default, which may not be enough time to process all of the validations and then write them to your workstation that is running ArcGIS Pro. For larger data loads, it is recommended that you adjust the maximum file age to at least one hour. For steps to adjust this setting, see Edit a server directory in Manager.


Usage


Syntax

Parameter Explanation
source_routes

The input from which the routes will be derived. The input can be a polyline feature class, shapefile, feature service, or LRS Network feature class.

in_lrs_network

The target LRS Network into which the routes will be loaded.

route_id_field

The field in the input polyline feature class that will be mapped to the LRS Network route ID. The field type must match the RouteID field type of the target LRS Network and must be either a string or GUID field type. If it is a text field, the field length must be shorter than or equal to the length of the target RouteID field.

route_name_field

The field in the input polyline feature class that will be mapped as the LRS Network route name. The field must be a string field, and the field length must be shorter than or equal to the length of the target route name field.

from_date_field (Optional)

A date field in the input polyline feature class that will be mapped as the LRS Network from date. If a from date field is not mapped, a null value representing the beginning of time will be provided for all appended routes.

to_date_field (Optional)

A date field in the input polyline feature class that will be mapped as the LRS Network to date. If a to date field is not mapped, a null value representing the end of time will be provided for all appended routes.

line_id_field (Optional)

The field in the input polyline feature class that will be mapped as the LRS Network line ID. This parameter is only used if the target is an LRS Line Network. The field type must match the RouteID field type of the centerline sequence table and must be either a string of exactly 38 characters or a GUID field type.

line_name_field (Optional)

The string field in the input polyline feature class that will be mapped as the LRS Network line name. This parameter is only used if the target is an LRS Line Network.

line_order_field (Optional)

The long integer field in the input polyline feature class that will be mapped as the LRS Network line order. This parameter is only used if the target is an LRS Line Network.

field_map (Optional)

Controls how the attribute information in the fields of the source routes is transferred to the input LRS Network. Fields cannot be added to or removed from the target LRS Network because the data of the source routes is appended to an existing LRS Network that has a predefined schema. While you can set merge rules for each output field, the tool will ignore those rules.

load_type (Optional)

Determines how appended routes with measure or temporality overlaps with identical route IDs as Target Network records are loaded into the network feature class.

  • Add—Appends the input routes into the target LRS Network. If any route ID in the source routes already exists in the target LRS Network with the same temporality, it will be written to the output log as a duplicate route and must be corrected or filtered out before completing the loading process. This is the default.
  • Retire by route ID—Appends the input routes into the target LRS Network and retires any routes in the target LRS Network that have the same route ID and temporality overlap as the appended routes. If the appended route eclipses a target route with the same route ID, the target route is deleted.
  • Replace by route ID—Appends the input routes into the target LRS Network and deletes any routes in the target LRS Network with the same route ID as the appended routes.

Code Samples

AppendRoutes example 1 (Python window)

Demonstrates how to use the AppendRoutes tool in the Python window.


#This will append routes into an existing LRS Network, replacing the existing routes where an overlap occurs

# tool variables
source_routes = "C:\\Data\\UPDM.gdb\\EngineeringNetwork"
in_lrs_network = "C:\\Data\\NY_Data.gdb\\P_Integrity\\P_EngineeringNetwork"
route_id_field = "RouteId"
route_name_field = "RouteName"
from_date_field = "FromDate"
to_date_field = "ToDate"
line_id_field = "LineId"
line_name_field = "LineName"
line_order_field = "LineOrder"
field_map = None
load_type = "REPLACE_BY_ROUTE_ID"

# execute the tool
arcpy.AppendRoutes_locref(source_routes, in_lrs_network, route_id_field, route_name_field, from_date_field, to_date_field, line_id_field, line_name_field, line_order_field, field_map, load_type)

                    

AppendRoutes example 2 (stand-alone script)

Demonstrates how to use the AppendRoutes tool as a stand-alone Python script.


# Name: AppendRoutes_ex2.py
# Description: Append records into an existing Pipeline Referencing network feature class without performing any attribute field mapping.
# Requires: ArcGIS Pipeline Referencing

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("LocationReferencing")

# Local variables:
SourceRoutes = "C:\\Data\\UPDM.gdb\\EngineeringNetwork"
TargetNetwork = "C:\\Data\\NY_Data.gdb\\P_Integrity\\P_EngineeringNetwork"
Route_ID = "RouteId"
Route_Name = "RouteName"
From_Date = "FromDate"
To_Date = "ToDate"
Line_ID = "LineId"
Line_Name = "LineName"
Line_Order = "LineOrder"

# Process: Append Routes
arcpy.AppendRoutes_locref(SourceRoutes, TargetNetwork, "RouteId", "RouteName", "FromDate", "ToDate", "LineId", "LineName", "LineOrder", None, "ADD")


                    

AppendRoutes example 3 (stand-alone script)

Demonstrates how to use the AppendRoutes tool as a stand-alone Python script for a user-generated route ID network.


# Name: AppendRoutes_ex3.py
# Description: Append records into an existing usergenerated routeid network feature class
# Source fields : RS and RN, Target fields : RouteSystem and RouteNumber
# Requires: Location Referencing 

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("LocationReferencing")

# Local variables:
SourceRoutes = r"C:\Data\DOT.gdb\RoutestoAppend"
TargetNetwork = r"C:\Data\DOT.gdb\StateRoutes"
RouteId = "RouteId"
RouteName = ""
FromDate = "FromDate"
ToDate = "ToDate"
LineId = ""
LineName = ""
LineOrder = ""
loadtype = "ADD"

# Define field mappings object
fieldMappings = arcpy.FieldMappings()  

  
# Add input fields
fldmap1 = arcpy.FieldMap()
fldmap1.addInputField(SourceRoutes, "RS")

fldmap2 = arcpy.FieldMap()
fldmap2.addInputField(SourceRoutes, "RN")

# Set output fields
fld1 = fldmap1.outputField  
fld1.name = "RouteSystem"
fld1.aliasName = "RouteSystem"
fldmap1.outputField = fld1

fld2 = fldmap2.outputField  
fld2.name = "RouteNumber"
fld2.aliasName = "RouteNumber"
fldmap2.outputField = fld2

# Add output fields to field mappings object
fieldMappings.addFieldMap(fldmap1)
fieldMappings.addFieldMap(fldmap2)

# Execute: Append Routes
arcpy.AppendRoutes_locref(SourceRoutes, TargetNetwork, RouteId, RouteName, FromDate, ToDate, LineId, LineName, LineOrder, fieldMappings, loadtype)

                    

AppendRoutes example 4 (stand-alone script)

Demonstrates how to use the AppendRoutes tool as a stand-alone Python script in a feature service.


# Name: AppendRoutes_Pro_Ex4.py
# Description: This script demonstrates how to use append routes in stand alone mode using a feature service. It is recommended to work in a version and post it into the default version.
# Requires: Location Referencing license

# Import arcpy module.
import arcpy

# Check out any necessary licenses.
arcpy.CheckOutExtension("LocationReferencing")

# Setting tool variables.

sourceroute = "C:\\LocationReferencing\\LR.gdb\\routes"
route_name_field = "ROUTENAME"
from_date_field = "FROMDATE"
to_date_field = "TODATE"
line_id_field = "LINEID"
line_name_field = "LINENAME"
line_order_field = "ORDERID"
field_mapping = r'CREATIONUSER "Creation User" true true false 50 Text 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,CREATIONUSER,0,50;DATECREATED "Date Created" true true false 8 Date 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,DATECREATED,-1,-1;DATEMODIFIED "Date Modified" true true false 8 Date 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,DATEMODIFIED,-1,-1;LASTUSER "Last User" true true false 50 Text 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,LASTUSER,0,50;EVENTSOURCE "Event Source" true true false 50 Text 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,EVENTSOURCE,0,50;LEGACYID "Legacy ID" true true false 38 Text 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,LEGACYID,0,38;ENGFROMM "ENGFROMM" true true false 0 Double 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,ENGFROMM,-1,-1;ENGTOM "ENGTOM" true true false 0 Double 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,ENGTOM,-1,-1;OBJECTSTATUS "Object Status" true true false 20 Text 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,OBJECTSTATUS,0,20;CONTINFROMM "Continuous from Measure" true true false 0 Double 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,CONTINFROMM,-1,-1;CONTINTOM "Continuous to Measure" true true false 0 Double 0 0,First,#,C:\\LocationReferencing\\LR.gdb\\routes,CONTINTOM,-1,-1'
load_type = "REPLACE_BY_ROUTE_ID"

## Target Route  is in feature service. Signing in portal is required to access the feature service.
arcpy.SignInToPortal('https://yourdomain.com/portal', 'username', 'password')

## Map the target route network from the feature service.Here, 18 corresponds to the target route network.
targetroute_network = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/18"


# Process: Append Routes.
arcpy.locref.AppendRoutes(sourceroute, targetroute_network, route_id_field, route_name_field, from_date_field, to_date_field, line_id_field, line_name_field, line_order_field, field_mapping, load_type)


                    

Tags

Credits

Use limitations