I have M-enabled polylines, these lines are calibrated using different calibration points and some even start from zero. I want to drop existing M-values and then want to assign distance as M-value.

I can do this in ArcMap as you can see in the images below:

Dropping existing M-values.

Drop Measures

Recalculating using Set as Distance.

Recalculate M-values based on Distance

I have many such polylines and I am trying to automate it using arcpy but could not find anything related to this.

Note: There is a tool "Create Route", but it requires coordinate_priority which changes the direction of the line. I need to recalibrate line based on distance with direction preserved.

  • Feature to vertices (both ends). Use orig_fid to transfer line length to every even point. Use points to calibrate routes. Set measure to 0 for odd points – FelixIP Mar 18 at 18:42

You could probably use the "Create Route" Tool, it is intended for creating new route but it will probably work on existing route by just updating the M value (note that it will create a new layer)

The help page of the tool has example on how to use it in a python script (you could also use it directly from the tool box)

  • This creates route on above that line, it does not change the M-value of the actual line. – Ayaz49 Mar 18 at 15:27
  • 1
    If you what you choose as route ID was a unique ID you now have an identical set of polyline the only difference being the that the M value is set to length. So you can replace your original set by the new one or delete the original polyline and load the new one... – J.R Mar 18 at 16:36
  • Its changing the direction of the line. – Ayaz49 Mar 22 at 16:01

I know you've tagged this as arcpy but this could be solved with a little VBA and the ArcObjects interface IMSegmentation3. I would preselect the lines you want to recalibrate and then update the geometries in the mxd with some VBA.

I know ArcObjects can be exposed to python using comtypes, but I've never done that as I know how to code in VBA which is quicker for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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