Flip Route

Flips slected routes in a Feature Class. The routes to flip are identified by a Layer File. The tool can flip either 1) the measure direction of the selected routes, 2) the feature direction, or 3) both measure and feature direction.

Command line syntax

fliproute <Input_Layer_File> {Output_Feature_Class} {BOTH | MEASURE_DIRECTION | FEATURE_DIRECTION}

Parameters

Expression Explanation
<Input_Layer_File>

The input Layer File that identifies which routes are to be flipped.

To create this Layer File, you can, for example, select the routes that are to be flipped using ArcMap, right click on this layer within the table of contents, and select Save As Layer File...

{Output_Feature_Class}

The name for the output Feature Class.

If no Output Feature Class is specified, then the Input Feature Class will be updated.

If an Output Feature Class is specified, then it must not already exist.

If an Output Feature Class is specified, then only the features selected in the Input Layer File will be written to the Output Feature Class.

{BOTH | MEASURE_DIRECTION | FEATURE_DIRECTION}

This option specifies what is to be flipped.

MEASURE_DIRECTION - The measures are reversed along each route.

The new measures along each route are calculated by subtracting the original measure of each vertex from the maximum measure of the route.

For example, if a route starts at milepost 0 and ends at milepost 10, after flipping the measures the route will start at milepost 10 and end at milepost 0.

The measure length of every portion of the route is kept the same. In other words, if a particular stretch of a route has a measure length of 1 mile, it will still be 1 mile after the measures are flipped.

FEATURE_DIRECTION - The order of the vertices are reversed along each route.

The measure value of each vertex is kept the same.

For example, if a route starts at its west end at milepost 0, proceeds east, and ends at milepost 10, after flipping the feature the route will start at its east end at milepost 10, proceed west, and end at milepost 0.

BOTH - Both the measures and the order of the vertices are reversed along each route.

Using the BOTH option yields the same results as running the tool twice, once using MEASURE_DIRECTION and the other time using FEATURE_DIRECTION.

For example, if a route starts at its west end at milepost 0, proceeds east, and ends at milepost 10, after flipping the feature the route will start at its east end at milepost 0, proceed west, and end at milepost 10.

The measure length of every portion of the route is kept the same. In other words, if a particular stretch of a route has a measure length of 1 mile, it will still be 1 mile after the measures and vertex order are flipped.

If no Flip Option is specified, BOTH is used by default.

Command Line Example

workspace c:\docume~1\dchatfie\mydocu~1\linear~1
Set c:\docume~1\dchatfie\mydocu~1\linear~1 into workspace

fliproute routes_to_flip.lyr
Executing (fliproute_8): fliproute "C:\Documents and Settings\dchatfie\My Documents\linear_referencing\routes_to_flip.lyr" # BOTH
Start Time: Tue Apr 25 15:32:49 2006
Running script fliproute...
Completed script fliproute...
Executed (fliproute_8) successfully.
End Time: Tue Apr 25 15:32:56 2006 (Elapsed Time: 7.00 secs)

Scripting syntax

fliproute (Input_Layer_File, Output_Feature_Class, Flip_Option)

Parameters

Expression Explanation
Input Layer File (Required)

The input Layer File that identifies which routes are to be flipped.

To create this Layer File, you can, for example, select the routes that are to be flipped using ArcMap, right click on this layer within the table of contents, and select Save As Layer File...

Output Feature Class (Optional)

The name for the output Feature Class.

If no Output Feature Class is specified, then the Input Feature Class will be updated.

If an Output Feature Class is specified, then it must not already exist.

If an Output Feature Class is specified, then only the features selected in the Input Layer File will be written to the Output Feature Class.

Flip Option (Optional)

This option specifies what is to be flipped.

MEASURE_DIRECTION - The measures are reversed along each route.

The new measures along each route are calculated by subtracting the original measure of each vertex from the maximum measure of the route.

For example, if a route starts at milepost 0 and ends at milepost 10, after flipping the measures the route will start at milepost 10 and end at milepost 0.

The measure length of every portion of the route is kept the same. In other words, if a particular stretch of a route has a measure length of 1 mile, it will still be 1 mile after the measures are flipped.

FEATURE_DIRECTION - The order of the vertices are reversed along each route.

The measure value of each vertex is kept the same.

For example, if a route starts at its west end at milepost 0, proceeds east, and ends at milepost 10, after flipping the feature the route will start at its east end at milepost 10, proceed west, and end at milepost 0.

BOTH - Both the measures and the order of the vertices are reversed along each route.

Using the BOTH option yields the same results as running the tool twice, once using MEASURE_DIRECTION and the other time using FEATURE_DIRECTION.

For example, if a route starts at its west end at milepost 0, proceeds east, and ends at milepost 10, after flipping the feature the route will start at its east end at milepost 0, proceed west, and end at milepost 10.

The measure length of every portion of the route is kept the same. In other words, if a particular stretch of a route has a measure length of 1 mile, it will still be 1 mile after the measures and vertex order are flipped.

If no Flip Option is specified, BOTH is used by default.

Script Example

# Import modules.
import sys, string, os, win32com.client

# Create the Geoprocessor object
gp = win32com.client.Dispatch('esriGeoprocessing.GpDispatch.1')

# Load required toolboxes...
gp.AddToolbox('C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx')

# Load DV Linear Referencing toolbox.
gp.AddToolbox('C:/Documents and Settings/dchatfie/Application Data/ESRI/ArcToolbox/My Toolboxes/' + \
                         'DV Linear Referencing Tools.tbx')

# Set workspace.
gp.workspace = 'c:/documents and settings/dchatfie/my documents/linear_referencing'

# Select routes to flip.
gp.makefeaturelayer('roads.shp', 'lyr')
gp.selectlayerbyattribute('lyr', 'new_selection', '"flip" = 1')
gp.savetolayerfile('lyr', 'routes_to_flip.lyr')

# Run flip route script.
gp.fliproute('routes_to_flip.lyr')