#You have a point feature class of graffiti incidents and a polygon feature class of patrol zones with some empty attributes #already created for you. You must write a script that updates the attributes of the patrol zones with: #The number of graffiti incidents falling within the patrol zone. This is an integer that goes in the INCIDENTS field. #The priority ranking for the patrol zone. This is a string that goes in the PRIORITY field. You will derive this string using some simple math that compares the number of incidents in the zone with the area of the zone import arcpy arcpy.env.overwriteOutput = True PatrolZones = "D:\\WCGIS\\Geog485\\Lesson3PracticeExerciseB\\Washington.gdb\\CityBoundaries" Graffiti = "D:\\WCGIS\\Geog485\\Lesson3PracticeExerciseB\\Washington.gdb\\ParkAndRide" GraffitiField = "INCIDENTS" ZoneField = "PRIORITY" valueList = [] # array to hold list of values collected valueSet = set() # set to hold values to test against to get list rows = arcpy.SearchCursor(inputTable) # create search cursor # iterate through table and collect unique values for row in rows: value = row.getValue(field) # add value if not already added and not current year if value not in valueSet: valueList.append(value) # add value to valueset for checking against in next iteration valueSet.add(value) # return value list valueList.sort() #return valueList
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question