Hi I need help with writing a script:The taskI have a point feature class of graffiti incidents and a polygon feature class of patrol zones with some empty attributes already created for you. I 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.Patrol zone priority rankingsI then will calculate a priority ranking for each zone by dividing the number of graffiti incidents in the zone by the area of the zone. My script should then examine the result and assign the appropriate priority ranking (PRIORITY). These are the priority rankings:�?� TOP CONCERN�??15 or more incidents per square mile�?� HIGH CONCERN�?? At least 12 but less than 15 incidents per square mile�?� SOME CONCERN�?? At least 6 but less than 12 incidents per square mile�?� LOW CONCERN�??Fewer than 6 incidents per square mileHere's what I have so far:import arcpyarcpy.env.overwriteOutput= True# layer that we are changingpatrolZone= "C:\\...\\PoliceData.gdb\\PatrolZones"# the layer we are selecting fromgraffiti= "C:\\...\\PoliceData.gdb\\GraffitiIncidents"nameField= "NAME"graffitiField= "OBJECTID"incidentsField= "INCIDENTS"# sits above the first row, starts the cursorpatrolRows= arcpy.UpdateCursor(patrolZone)# tells it to go to the first rowpatrol= patrolRows.next()# now were in the first row doing loopingwhile patrol: arcpy.MakeFeatureLayer_management(graffiti, "GraffitiLayer") zones= patrol.getValue(nameField) #print incidents queryString = '"' + str(nameField) + '" = ' + "'" + str(zones) + "'" print str(queryString) arcpy.MakeFeatureLayer_management(patrolZone, "PatrolLayer", queryString) arcpy.SelectLayerByLocation_management("GraffitiLayer", "CONTAINED_BY", "PatrolLayer") numGraffiti= arcpy.GetCount_management("GraffitiLayer") print numGraffiti patrol= patrolRows.next() I would appreciate any help!!
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.