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
|
指定将用于输出中的长度字段的测量单位。
INCHES—将以英寸为单位。
FEET—单位将为英尺。
YARDS—单位将为码。
MILES—单位将为英里。
NAUTICAL_MILES—单位将为海里。
INTFEET—单位将为国际英尺。
INTMILES—单位将为法定英里。
MILLIMETERS—单位将为毫米。
CENTIMETERS—单位将为厘米。
METERS—单位将为米。
KILOMETERS—单位将为千米。
DECIMETERS—单位将为分米。
|
String
|
|
summary_fields
[summary_fields,...]
(可选)
|
用于展示输出中的汇总行名称的图层字段。
值表列:
Layer—The feature layer that will be used as the summary layer.
Field—The field that will be used to summarize the length.
Output Field Name—The summary field's display name in the output.
|
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 示例 1(独立脚本)
以下独立脚本演示了如何在独立脚本中使用 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
# 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)
GenerateLRLengthSummary 示例 2(Python 窗口)
以下脚本演示了如何在 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 示例 3(独立脚本)
以下独立脚本演示了如何将 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
# 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)