| Label | Explanation | Data Type |
Input Route Features | The route features that will be used to create the feature count data product. | Feature Layer |
Effective Date | The date that will be used to define the temporal view of the network. The default value is today's date. | Date |
Summary Fields (Optional) | The fields that will be used to show the names for the summary rows in the output.
| Value Table |
Feature Count Layers (Optional) | The layers that will be used to locate the number of features along a route.
| Value Table |
Exclude null summary rows (Optional) | Specifies whether null summary rows will be excluded from the output.
| Boolean |
Output Format (Optional) | Specifies the format of the output.
| String |
Output File (Optional) | The output .csv file that will contain the feature count data product. | File |
Output Table (Optional) | The output geodatabase table that will contain the feature count data product. | Table |
Available with Location Referencing license.
Summary
Creates a feature count data product for routes in an LRS Network without an LRS data template.
Usage
This tool supports data from a file geodatabase, an enterprise geodatabase (branch versioned connection), or a feature service (published from branch versioned data).
This tool does not modify the inputs and will create a .csv file or a geodatabase table as the output.
The Effective Date parameter is used to define the temporal view of the network. Only routes active on this date will be used to calculate the output.
The summary layer must be a polygon feature class, an LRS line event feature class that is registered to the specified LRS Network, or an LRS Network.
A value of unclassified will be included in the output summary field for routes that do not overlap with the summary layers.
You can add multiple summary fields.
The output will be created based on the intersection of selected features from the LRS Network, summary layers, and feature count layers.
The feature count layer must be an LRS point event feature class, an LRS line event feature class, or an LRS intersection feature class that is registered to the specified LRS Network.
A value of unclassified will be included in the output feature count fields for routes that do not overlap with the feature count layers.
The summary and feature count layers must be stored in the same geodatabase or feature service and have the same coordinate system as the specified LRS Network.
You can add multiple feature count layers from the same feature class by creating selection layers and specifying each selection layer as a feature count layer. For example, if you have an LRS point event feature class, you can create two selection layers—Class A and Class B—and specify each selection layer as a feature count layer.
Parameters
arcpy.locref.GenerateLRFeatureCount(in_route_features, effective_date, {summary_fields}, {feature_count_layers}, {exclude_null_summary_rows}, {output_format}, {out_file}, {out_table})| Name | Explanation | Data Type |
in_route_features | The route features that will be used to create the feature count data product. | Feature Layer |
effective_date | The date that will be used to define the temporal view of the network. The default value is today's date. | Date |
summary_fields [summary_fields,...] (Optional) | The fields that will be used to show the names for the summary rows in the output.
| Value Table |
feature_count_layers [feature_count_layers,...] (Optional) | The layers that will be used to locate the number of features along a route.
| Value Table |
exclude_null_summary_rows (Optional) | Specifies whether null summary rows will be excluded from the output.
| Boolean |
output_format (Optional) | Specifies the format of the output.
| String |
out_file (Optional) | The output .csv file that will contain the feature count data product. | File |
out_table (Optional) | The output geodatabase table that will contain the feature count data product. | Table |
Code sample
The following stand-alone script demonstrates how to use the GenerateLRFeatureCount function in a stand-alone script.
# Name: GenerateLRFeatureCount_ex1.py
# Description: Create a feature count data product that provides the number of active anomalies, pipeline crossings, and DOT Class line events per route
# 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"
# Using the Anomaly point event feature class, create a feature layer that contains active anomalies, to be used as a feature count layer
arcpy.management.MakeFeatureLayer("Anomaly", "Anomaly_Active", "anomalystatus = 'Active'")
# Using the DOT Class line event feature class, create 3 feature layers, each representing a class type, to be used as feature count layers
arcpy.management.MakeFeatureLayer("DOTClass", "Class_A", "classtype = 1")
arcpy.management.MakeFeatureLayer("DOTClass", "Class_B", "classtype = 2")
arcpy.management.MakeFeatureLayer("DOTClass", "Class_C", "classtype = 3")
# Set tool variables
in_route_features = "EngineeringNetwork"
effective_date = "12/31/2024"
summary_fields = "Counties NAME Counties"
feature_count_layers = "Anomaly_Active 'Anomaly'; PipeCrossing 'Pipe Crossings'; Class_A 'Class A'; Class_B 'Class B'; Class_C 'Class C'"
exclude_null_summary_rows = "EXCLUDE"
output_format = "TABLE"
out_file = None
out_table = r"C:\Data\SampleData.gdb\FC1"
# Run the tool
arcpy.locref.GenerateLRFeatureCount(in_route_features, effective_date, summary_fields, feature_count_layers, exclude_null_summary_rows, output_format, out_file, out_table)
# Check in licenses
arcpy.CheckInExtension("LocationReferencing")The following script demonstrates how to use the GenerateLRFeatureCount function in the Python window.
# Name: GenerateLRFeatureCount_ex2.py
# Description: Create a feature count data product that provides the number of bridges and intersections per route
# Requirements: ArcGIS Location Referencing
# Set tool variables
in_route_features = "CountyLog"
effective_date = "12/31/2024"
summary_fields = "Counties NAME Counties"
feature_count_layers = "Bridge_Point 'Bridges'; Intersections 'Intersections'"
exclude_null_summary_rows = "EXCLUDE"
output_format = "TABLE"
out_file = None
out_table = r"C:\Data\SampleData.gdb\FC2"
# Run the tool
arcpy.locref.GenerateLRFeatureCount(in_route_features, effective_date, summary_fields, feature_count_layers,
exclude_null_summary_rows, output_format, out_file, out_table)The following stand-alone script demonstrates how to use the GenerateLRFeatureCount function with data from a feature service.
# Name: GenerateLRFeatureCount_ex3.py
# Description: Create a feature count data product that provides the number of active anomalies, pipeline casing material types, and crossing utility intersections per route
# Requirements: 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, 49 corresponds to the LRS Network's layer ID
in_route_features = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/49"
# Create a feature layer from the Cities layer of the feature service to be used as the summary layer. Here, 21 corresponds to the Cities layer's layer ID
arcpy.management.MakeFeatureLayer(r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/21", "Cities")
# Create the feature layers from the feature service. The feature layers will be used as feature count layers
arcpy.management.MakeFeatureLayer(r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/18", "Anomaly_Active", "anomalystatus = 'Active'")
arcpy.management.MakeFeatureLayer(r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/54", "Casing_CastIron", "MATERIAL = 2")
arcpy.management.MakeFeatureLayer(r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/54", "Casing_Copper", "MATERIAL = 4")
arcpy.management.MakeFeatureLayer(r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/54", "Casing_Composite", "MATERIAL = 10")
arcpy.management.MakeFeatureLayer(r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/61", "Crossing_Utility_Intersection")
# Set tool variables
effective_date = "12/31/2024"
summary_fields = "Cities NAME Cities"
feature_count_layers = "Anomaly_Active 'Anomalies'; Casing_CastIron 'Cast Iron Casing'; Casing_Copper 'Copper Casing'; Casing_Composite 'Composite Casing'; Crossing_Utility_Intersection 'Crossing Utility Intersections'"
exclude_null_summary_rows = "EXCLUDE"
output_format = "CSV"
out_file = r"C:\Data\FC3.csv"
out_table = None
# Run the tool
arcpy.locref.GenerateLRFeatureCount(in_route_features, effective_date, summary_fields, feature_count_layers,
exclude_null_summary_rows, output_format, out_file, out_table)
# Check in the license
arcpy.CheckInExtension("LocationReferencing")Environments
Licensing information
- Basic: Requires ArcGIS Location Referencing (ArcGIS Pipeline Referencing or ArcGIS Roads and Highways)
- Standard: Requires ArcGIS Location Referencing (ArcGIS Pipeline Referencing or ArcGIS Roads and Highways)
- Advanced: Requires ArcGIS Location Referencing (ArcGIS Pipeline Referencing or ArcGIS Roads and Highways)