创建路径 (线性参考)

许可等级:BasicStandardAdvanced

摘要

根据现有的线创建路径。如果输入线状要素具有相同的标识符,则将它们将合并以创建单条路径。

用法

语法

CreateRoutes_lr (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})
参数说明数据类型
in_line_features

用于创建路径的要素。

Feature Layer
route_id_field

包含可唯一识别每条路径的值的字段。

Field
out_feature_class

要创建的要素类。它可以是 shapefile,也可以是地理数据库要素类。

Feature Class
measure_source

指定如何获取路径测量值。

  • LENGTH使用输入要素的几何长度累积测量值。这是默认设置。
  • ONE_FIELD使用单个字段中存储的值累积测量值。
  • TWO_FIELDS使用“测量始于字段”和“测量止于字段”中存储的值设置测量值。
String
from_measure_field
(可选)

包含测量值的字段。该字段必须为数值,并且在测量源是 ONE_FIELD 或 TWO_FIELDS 时必填。

Field
to_measure_field
(可选)

包含测量值的字段。该字段必须为数值,并且在测量源是 TWO_FIELDS 时必填。

Field
coordinate_priority
(可选)

用于为每条输出路径累积测量值的位置。在测量源是 TWO_FIELDS 时将忽略此参数。

  • UPPER_LEFT从最接近最小外接矩形左上角的点累积测量值。这是默认设置。
  • LOWER_LEFT从最接近最小外接矩形左下角的点累积测量值。
  • UPPER_RIGHT从最接近最小外接矩形右上角的点累积测量值。
  • LOWER_RIGHT从最接近最小外接矩形右下角的点累积测量值。
String
measure_factor
(可选)

合并输入线创建路径测量值之前,每条输入线的测量长度乘以的值。默认值为 1。

Double
measure_offset
(可选)

合并输入线创建路径后,加到路径测量值的值。默认值为 0。

Double
ignore_gaps
(可选)

指定在计算不相交路径上的测量值时是否忽略空间间距。此参数适用于测量源是 LENGTH 或 ONE_FIELD 的情况。

  • IGNORE忽略空间间距。不相交路径的测量值将是连续的。这是默认设置。
  • NO_IGNORE不忽略空间间距。不相交路径的测量值将有间距。将使用不相交部分的端点间的直线距离来计算间距。
Boolean
build_index
(可选)

指定是否为写入输出路径要素类的路径标识符字段创建属性索引。

  • INDEX创建属性索引。这是默认设置。
  • NO_INDEX不创建属性索引。
Boolean

代码实例

CreateRoutes 示例(Python 窗口)

以下 Python 窗口脚本演示了如何在 Python 窗口中使用 CreateRoutes 函数。

import arcpy
from arcpy import env
env.workspace = "C:/Data"
arcpy.CreateRoutes_lr(base_roads.shp, "route1", "newRoutes", "LENGTH", "#", "#", "LOWER_LEFT", 0.00018939394)
CreateRoutes 示例 2(独立 Python 脚本)

以下 Python 脚本演示了如何在独立 Python 脚本中将 CreateRoutes 函数与 shapefile 数据结合使用。

# 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.
# Author: ESRI

# Import system modules
import arcpy
from arcpy import env

# Set workspace
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 示例 3(独立 Python 脚本)

以下 Python 脚本演示了如何在独立 Python 脚本中将 CreateRoutes 函数与文件地理数据库数据结合使用。

# 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
from arcpy import env

# Set workspace
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 the result to the roads feature dataset

# Execute CreateRoutes
arcpy.CreateRoutes_lr(in_lines, rid, out_routes, "ONE_FIELD", m_fld, "#", "LOWER_LEFT")
CreateRoutes 示例 4(独立 Python 脚本)

以下 Python 脚本演示了如何在独立 Python 脚本中将 CreateRoutes 函数与个人地理数据库数据结合使用。

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

# Import system modules 
import arcpy
from arcpy import env

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

# 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 the result to the roads feature dataset 

# Execute CreateRoutes
arcpy.CreateRoutes_lr(in_lines, rid, out_routes, "ONE_FIELD", m_fld, "#", "LOWER_LEFT")
CreateRoutes 示例 5(独立 Python 脚本)

以下 Python 脚本演示了如何在独立 Python 脚本中将 CreateRoutes 函数与 SDE 数据结合使用。

# Name CreateRoutes_Example5.py
# Description:  Create routes from lines. The lines are in an enterprise geodatabase.
# The TWO_FIELD option will be used to set the measures.
# Author: ESRI
 
# Import system modules
import arcpy
from arcpy import env

# Set workspace
env.workspace = "Database Connections/Connection to Jerry.sde"

# Set local variables
in_lines = gp.QualifyTableName("base_roads", wkspc)   # base_roads is a standalone feature class
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)

环境

相关主题

许可信息

ArcGIS for Desktop Basic: 是
ArcGIS for Desktop Standard: 是
ArcGIS for Desktop Advanced: 是
5/10/2014