Tuesday, 8 December 2015

arcgis 10.2 - Determining Min/Max values from feature class using ArcPy?


I am very rusty/inexperienced in Python.


I would like to create a more compact script that prints min and max values of each numeric field from a feature class. Right now I have the code below repeated for each field that contains numeric values.


How would I code this to identify if a field has numeric values and then print the min and max values to the python shell or even better to a .csv/text file?


import arcpy
data = "C:/Workfolder/Input.gdb/FeatureClass"

listname = []
cursor = arcpy.da.SearchCursor(data, "field1")


for row in cursor:
listname.append(int(row[0]))

print 'Field1_min, {0}'.format(min(listname))
print 'Field2_max, {0}'.format(max(listname))


No comments:

Post a Comment