| 标注 | 说明 | 数据类型 |
输入路径要素 | 用于计算 LRS 长度数据产品的路径要素。 | Feature Layer |
生效日期 | 定义网络时态视图的日期。 默认值为当前日期。 | Date |
长度单位 | 指定将用于输出中的长度字段的测量单位。
| String |
汇总字段 (可选) | 用于展示输出中的汇总行名称的图层字段。
| Value Table |
长度字段 (可选) | 图层字段将用于展示输出中的路径长度。
| Value Table |
排除空汇总行 (可选) | 指定是否排除空的汇总行。
| Boolean |
计算主要路径的长度 (可选) | 注:未来版本中将添加对此参数的支持。 | Boolean |
输出格式 (可选) | 指定输出的格式。
| String |
输出文件 (可选) | 将包含长度数据产品的输出 .csv 文件。 | File |
输出表 (可选) | 将包含长度数据产品的输出地理数据库表。 | Table |
适用于 Location Referencing 许可。
摘要
用于在没有 LRS 数据模板的情况下,创建 LRS 网络中路径的长度数据产品。
使用情况
此工具支持来自文件地理数据库、企业级地理数据库(分支版本化连接)或要素服务(根据分支版本化数据发布)的数据。
此工具不会修改输入,并将创建 .csv 文件或地理数据库表作为输出。
生效日期参数用于确定网络的时态视图。 仅使用在该日期处于活动状态的路径计算输出。
汇总图层必须是面要素类、注册至指定 LRS 网络的 LRS 线事件要素类或 LRS 网络。
长度图层必须是 LRS 网络或注册至指定 LRS 网络的 LRS 线事件要素类。
汇总和长度图层必须存储在相同的地理数据库或要素服务中,并且与指定的 LRS 网络具有相同的坐标系。
对于未与汇总图层重叠的路径,其输出汇总字段中将包含值“未分类”。
可添加多个汇总字段。
输出将基于 LRS 网络中选择的要素、汇总图层以及长度图层的交集而创建。
可通过创建选择图层并将每个选择图层指定为长度字段,而从同一个要素类添加多个长度字段。 例如,如果您具有 LRS 线事件要素类,则可创建两个选择图层 - A 类和 B 类 - 并将每个选择图层指定为长度字段。
参数
arcpy.locref.GenerateLRLengthSummary(in_route_features, effective_date, units, {summary_fields}, {length_fields}, {exclude_null_summary_rows}, {calculate_length_for_dominant_routes}, {output_format}, {out_file}, {out_table})| 名称 | 说明 | 数据类型 |
in_route_features | 用于计算 LRS 长度数据产品的路径要素。 | Feature Layer |
effective_date | 定义网络时态视图的日期。 默认值为当前日期。 | Date |
units | 指定将用于输出中的长度字段的测量单位。
| String |
summary_fields [summary_fields,...] (可选) | 用于展示输出中的汇总行名称的图层字段。
| Value Table |
length_fields [length_fields,...] (可选) | 图层字段将用于展示输出中的路径长度。
| Value Table |
exclude_null_summary_rows (可选) | 指定是否排除空的汇总行。
| Boolean |
calculate_length_for_dominant_routes (可选) | 注:未来版本中将添加对此参数的支持。 | Boolean |
output_format (可选) | 指定输出的格式。
| String |
out_file (可选) | 将包含长度数据产品的输出 .csv 文件。 | File |
out_table (可选) | 将包含长度数据产品的输出地理数据库表。 | Table |
代码示例
以下独立脚本演示了如何在独立脚本中使用 GenerateLRLengthSummary 函数。
# Name: GenerateLRLengthSummary_ex1.py
# Description: Create a length data product that provides the length of routes for three class types, summarized by counties with a population of more than 50,000
# Requirements: ArcGIS Location Referencing
# Import arcpy module
import arcpy
# Check out any necessary licenses
arcpy.CheckOutExtension("LocationReferencing")
# Set current workspace
arcpy.env.workspace = r"C:\Data\SampleData.gdb"
# Create a feature layer of counties that have more than 50,000 population, to be used as summary field
arcpy.management.MakeFeatureLayer("counties", "counties_50K", "POPULATION > 50000")
# Create 3 feature layers, each representing a class type, to be used as length fields
arcpy.management.MakeFeatureLayer("Class", "Class_A", "classtype = 1")
arcpy.management.MakeFeatureLayer("Class", "Class_B", "classtype = 2")
arcpy.management.MakeFeatureLayer("Class", "Class_C", "classtype = 3")
# Set tool variables
in_route_features = "Network"
effective_date = "12/31/2024"
units = "METERS"
summary_fields = "counties_50K NAME Counties"
length_fields = "Class_A 'Class A'; Class_B 'Class B'; Class_C 'Class C'"
exclude_null_summary_rows = "EXCLUDE"
calculate_length_for_dominant_routes = None
output_format = "CSV"
out_file = r"C:\Data\LP1.csv"
out_table = None
# Run the tool
arcpy.locref.GenerateLRLengthSummary(in_route_features, effective_date, units, summary_fields, length_fields,
exclude_null_summary_rows, calculate_length_for_dominant_routes,
output_format, out_file, out_table)
# Check in licenses
arcpy.CheckInExtension("LocationReferencing")以下脚本演示了如何在 Python 窗口中使用 GenerateLRLengthSummary 函数。
# Name: GenerateLRLengthSummary_ex2.py
# Description: Create a length data product that provides the length of routes for all class types, summarized by counties
# Requirements: ArcGIS Location Referencing
# Set tool variables
in_route_features = "Network"
effective_date = "12/31/2024"
units = "METERS"
summary_fields = "Counties NAME Counties"
length_fields = "'Class' 'Class'"
exclude_null_summary_rows = "DO_NOT_EXCLUDE"
calculate_length_for_dominant_routes = None
output_format = "CSV"
out_file = r"C:\Data\LP2.csv"
out_table = None
# Run the tool
arcpy.locref.GenerateLRLengthSummary(in_route_features, effective_date, units, summary_fields, length_fields,
exclude_null_summary_rows, calculate_length_for_dominant_routes,
output_format, out_file, out_table)以下独立脚本演示了如何将 GenerateLRLengthSummary 函数与要素服务中的数据配合使用。
# Name: GenerateLRLengthSummary_ex3.py
# Description: Using LRS data in a feature service, create a length data product that provides the length of routes
# for three class types, summarized by counties with a population of more than 50,000
# Requires: ArcGIS Location Referencing
# Import arcpy module
import arcpy
# Check out the license
arcpy.CheckOutExtension("LocationReferencing")
# Data is in a feature service. Signing in to the Enterprise portal is required to access the feature service
arcpy.SignInToPortal('https://yourdomain.com/portal', 'username', 'password')
# Map the LRS Network from the feature service. Here, 1 corresponds to the LRS Network's layer ID
in_route_features = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/1"
# Map the Counties layer from the feature service. Here, 39 corresponds to the Counties layer's layer ID
counties = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/39"
# Create a feature layer of counties that have more than 50,000 population, to be used as summary field
arcpy.management.MakeFeatureLayer(counties, "counties_50K", "POPULATION > 50000")
# Map the Class layer from the feature service. Here, 22 corresponds to the Class layer's layer ID
classlayer = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/22"
# Create 3 feature layers, each representing a class type, to be used as length fields
arcpy.management.MakeFeatureLayer(classlayer, "Class_A", "classtype = 1")
arcpy.management.MakeFeatureLayer(classlayer, "Class_B", "classtype = 4")
arcpy.management.MakeFeatureLayer(classlayer, "Class_C", "classtype = 7")
# Set tool variables
effective_date = "12/31/2024"
units = "METERS"
summary_fields = "counties_50K NAME Counties"
length_fields = "Class_A 'Class A'; Class_B 'Class B'; Class_C 'Class C'"
exclude_null_summary_rows = "EXCLUDE"
calculate_length_for_dominant_routes = None
output_format = "CSV"
out_file = r"C:\Data\LP3.csv"
out_table = None
# Run the tool
arcpy.locref.GenerateLRLengthSummary(in_route_features, effective_date, units, summary_fields, length_fields,
exclude_null_summary_rows, calculate_length_for_dominant_routes,
output_format, out_file, out_table)
# Check in the license
arcpy.CheckInExtension("LocationReferencing")环境
许可信息
- Basic: 需要 ArcGIS Location Referencing(ArcGIS Pipeline Referencing 或 ArcGIS Roads and Highways)
- Standard: 需要 ArcGIS Location Referencing(ArcGIS Pipeline Referencing 或 ArcGIS Roads and Highways)
- Advanced: 需要 ArcGIS Location Referencing(ArcGIS Pipeline Referencing 或 ArcGIS Roads and Highways)