I'm completly new with python and wanted to do this little project that would be very useful. What I want to do in the end is having a little window pop up and showing the highest value of a field but only for a specific range of values, like between 1000 and 2000. Here's an example:
| Field1 |
| 1001 |
| 1002 |
| 1003 |
| 2002 |
| 2005 |
| 3001 |
| 3003 |
| 3008 |
What I need in the end is a list like this (but for now I'd be happy to just print out the right values):
Zone1 = 1003 Zone2 = 2005 Zone3 = 3008 |
With advice and code from another place I managed to write this
import arcpy fc = 'C:\..............\Einzelpunkt.shp' fields = ['Identifika'] #setting up the max value variables Zone1=0 Zone2=0 # For each row in the attribute table, use if statements # to determine which category it is in and if it is bigger # than the current max value for that category, update the # max value variable with arcpy.da.SearchCursor(fc, fields) as cursor: for row in cursor: if row[0]<20000 and row[0]>Zone1: Zone1=row[0] elif row[0]<30000 and row[0]>Zone2: Zone2=row[0] #keep adding elif statements to cover the rest of the Zones #this will print out the last number used in the piano category print "Zone1="+str(Zone1) print "Zone2="+str(Zone2) break |
| |
From what I can understand the if statements only take into account the first value in the column, wich in the example shape I have is ~31000 wich makes the statements false and not change the variables.
How should I approach this?
Keep in mind I'm a complete beginner 🙂