ArcMap 10.7.1 — Oracle 18c EGDB — SDE.ST_GEOMETRY

I have existing SDE.ST_GEOMETRY polylines that have M-values (aka 'measure values' for linear referencing purposes).

I want to update the M-values for all the lines via an ArcPy script.

In my case, the M-values of lines should be the same as the cumulative length of the line. In other words, if we look at the image below, the M-values should be the same as the length of the line at a given vertex.

enter image description here


Using ArcPy, is there a way to set the M-values to the cumulative length of the line?

Note: Some of the lines have arcs. And some of the lines are multi-part.


Python: Working with Feature Data using ArcPy [YouTube Video from ESRI]

  • 2
    Have a look at the Polyline functions at: pro.arcgis.com/en/pro-app/2.8/arcpy/classes/polyline.htm . In particular: measureOnLine() and queryPointAndDistance(). Do they provide the values that you need? Feb 1, 2022 at 3:05
  • For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question.
    – PolyGeo
    Feb 1, 2022 at 3:32
  • Just use the calibrate routes tool.
    – Hornbydd
    Feb 1, 2022 at 10:47
  • @Hornbydd Good idea. If I understand correctly, the Calibrate Routes tool outputs a copy FC, it doesn't update an existing FC. Does that sound right? Any ideas how to update existing SHAPE values, without replacing the FC or replacing the records? (I suppose the Create Routes GP tool might also be worth considering.)
    – User1974
    Feb 1, 2022 at 15:13
  • Yes both tools generate a new Feature Class, probably best as there would be no undo if you edit in-situ.
    – Hornbydd
    Feb 1, 2022 at 17:12

1 Answer 1


I came up with a script seems to work:

import arcpy
connection = "Database Connections\my_conn.sde"
feature_class = connection + "\my_owner.my_fc"
spatial_reference = arcpy.Describe(feature_class).spatialReference

with arcpy.da.Editor(connection) as edit_session:
    with arcpy.da.UpdateCursor(feature_class, "SHAPE@") as cursor:
        for row in cursor:
            geometry = row[0].densify("ANGLE", 10000, 0.174533)
            parts = arcpy.Array()
            for part in geometry:
                points = arcpy.Array()
                for point in part:
                    point.M = geometry.measureOnLine(point)
            row[0] = arcpy.Polyline(parts, spatial_reference)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.