# Name: GenerateCalibrationPoints_ex3.py
# Description: Build calibration point features in an existing feature service in a stand-alone script.
# Requires: ArcGIS Location Referencing
# Import arcpy module
import arcpy
# Check out license
arcpy.CheckOutExtension("LocationReferencing")
# Input LRS route network and calibration point feature class are in feature service. Signing into portal is required to access the feature service.
arcpy.SignInToPortal('https://yourdomain.com/portal', 'username', 'password')
# Generate Calibration Points tool variables:
in_polyline_features = r"C:\Data\SourceData.gdb\LRS\SourceRoutes"
route_id_field = "RouteID"
from_date_field = "FromDate"
to_date_field = "ToDate"
calibration_direction = "MEASURE_DIRECTION"
calibration_method = "GEOMETRY_LENGTH"
# Map the LRS Network and Calibration Point feature class from the feature service. Here, 5 corresponds to the LRS Network and 1 corresponds to the Calibration Point feature class.
lrs_network = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/5"
in_calibration_point_feature_class = r"https://yourdomain.com/server/rest/services/FeatureServiceName/FeatureServer/1"
# Process: Generate Calibration Points
arcpy.locref.GenerateCalibrationPoints(in_polyline_features, route_id_field, from_date_field, to_date_field, in_calibration_point_feature_class, lrs_network, calibration_direction, calibration_method)
## Check in license
arcpy.CheckInExtension('LocationReferencing')