with arcpy.da.UpdateCursor(FClassOrTable, fields) as cursor: for row in cursor: row[1] = GetMmax(row[0])
Instead of using a function to breakdown that Mmax value, you could also just use the extent object, which comes as part of the Shape@. Like this:
with arcpy.da.UpdateCursor(FClassOrTable, fields) as cursor: for row in cursor: row[1] = row[0].extent.MMax
def main(): import arcpy # settings, replace with your own dataset and existing column name: FClassOrTable = r'C:\Project\_tmp\test.gdb\Mawares' outputField = 'MMax' # .. or make variable # FClassOrTable = arcpy.GetParameterAsText(0) # outputField = arcpy.GetParameterAsText(1) # update featureclass fields = ['SHAPE@',outputField] with arcpy.da.UpdateCursor(FClassOrTable, fields) as cursor: for row in cursor: row[1] = GetMmax(row[0]) cursor.updateRow(row) del row del cursor def GetMmax(geom): # get the max(M) from a geometry mmax = -9999 for part in geom.getPart(): for point in part: m = point.M if m > mmax: mmax = m return mmax if __name__ == '__main__': main()
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.