# Name: UpdateMeasuresFromLRS_Sample1.py
# Description: This will populate the Route ID and measures in the input layer based on overlapping routes from the network layer.
# The output is the input layer with the updated Route ID and measure values, and a .csv file with information on the updated features and errors.
# Requires: ArcGIS Location Referencing
# Check out license
arcpy.CheckOutExtension("LocationReferencing")
## Variables are supported from feature service only. Signing into Portal is required to access the feature service.
arcpy.SignInToPortal('https://yourdomain.com/portal', 'username', 'password')
# Initialize variables
# Map the lrs network from the feature service. Here, 8 corresponds to the lrs route network.
lrs_network_url = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/8"
lrs_network = arcpy.management.MakeFeatureLayer(lrs_network_url, "networkLayer")
# Map the input feature layer from the same feature service. Here, 18 corresponds to the input feature layer.
in_features_url = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/18"
in_features = arcpy.management.MakeFeatureLayer(in_features_url, "inputFeaturesLayer")
lrs_date="10/8/2019"
route_id_field = "ROUTEID"
from_measure_field = "FROMMEASURE"
to_measure_field = "TOMEASURE"
# Execute the tool
arcpy.locref.UpdateMeasuresFromLRS(lrs_network, lrs_date, in_features, route_id_field, from_measure_field, to_measure_field)
# Check in license
arcpy.CheckInExtension('LocationReferencing')