ArcGIS Pro has tools for working with M values. Are these functionalities available in arcpy?
Solved! Go to Solution.
Think you'll have to do it manually with a cursor and extracting the m from the point. Stealing a post from SO
lyr = r"C:\Users\...\Default.gdb\TEST_ROUTE"
fields = ['SHAPE@']
with arcpy.da.UpdateCursor(lyr, fields) as cursor:
for row in cursor:
partslist = []
partlist = []
array = None
feat = row[0]
partnum = 0
# Count the number of points in the current multipart feature
partcount = feat.partCount
pntcount = 0
# Enter while loop for each part in the feature (if a singlepart feature
# this will occur only once)
#
while partnum < partcount:
part = feat.getPart(partnum)
pnt = part.next()
# Enter while loop for each vertex
#
while pnt:
pntcount += 1
if not numpy.isnan(pnt.M):
partlist.append(arcpy.Point(pnt.X, pnt.Y, pnt.Z, pnt.M / 1000))
pnt = part.next()
# If pnt is null, either the part is finished or there is an
# interior ring
#
if not pnt:
pnt = part.next()
partslist.append(arcpy.Array(partlist))
array = arcpy.Array(partslist)
partlist = []
partnum += 1
polylinefeat = arcpy.Polyline(array)
row[0] = polylinefeat
cursor.updateRow(row)
Think you'll have to do it manually with a cursor and extracting the m from the point. Stealing a post from SO
lyr = r"C:\Users\...\Default.gdb\TEST_ROUTE"
fields = ['SHAPE@']
with arcpy.da.UpdateCursor(lyr, fields) as cursor:
for row in cursor:
partslist = []
partlist = []
array = None
feat = row[0]
partnum = 0
# Count the number of points in the current multipart feature
partcount = feat.partCount
pntcount = 0
# Enter while loop for each part in the feature (if a singlepart feature
# this will occur only once)
#
while partnum < partcount:
part = feat.getPart(partnum)
pnt = part.next()
# Enter while loop for each vertex
#
while pnt:
pntcount += 1
if not numpy.isnan(pnt.M):
partlist.append(arcpy.Point(pnt.X, pnt.Y, pnt.Z, pnt.M / 1000))
pnt = part.next()
# If pnt is null, either the part is finished or there is an
# interior ring
#
if not pnt:
pnt = part.next()
partslist.append(arcpy.Array(partlist))
array = arcpy.Array(partslist)
partlist = []
partnum += 1
polylinefeat = arcpy.Polyline(array)
row[0] = polylinefeat
cursor.updateRow(row)
This seems to do what I want. Thank you!