I have a Python 2.7 script that loops through GIS polylines and updates a coordinate.
The coordinate is called an "M" coordinate (aka a "Measure-value"). M coordinates are similar to X and Y coordinates, but are used for specialized linear referencing purposes.
import arcpy connection = "Database Connections\my_conn.sde" fc = connection + "\my_owner.my_fc" spatialRef = arcpy.Describe(fc).spatialReference with arcpy.da.Editor(connection) as editSession: with arcpy.da.UpdateCursor(fc, ["ASSET_ID", "SHAPE@"]) as cursor: for row in cursor: feature = row.densify ("ANGLE", 10000, 0.174533) partNum = 0 partArray = arcpy.Array() for part in feature: pointArray = arcpy.Array() n = len(part) for i in range(n): point = part.getObject(i) point.M = feature.measureOnLine(point) pointArray.append(point) partArray.append(pointArray) partNum += 1 row = arcpy.Polyline(partArray, spatialRef) cursor.updateRow(row)
How can the script be improved?