Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arcpy.MakeFeatureLayer_management("treatment_maps",'maps')
- arcpy.MakeFeatureLayer_management("points_2014",'points')
- cursor=arcpy.UpdateCursor("treatment_maps")
- for row in cursor:
- map=row.getValue('map_name')
- where='"map_name"' + '=' + ''' + str(map) + '''
- arcpy.SelectLayerByAttribute_management("maps","NEW_SELECTION",where)
- arcpy.SelectLayerByLocation_management("points","COMPLETELY_WITHIN","maps")
- count=arcpy.GetCount_management("points")
- row.setValue('DI_Count', count)
- cursor.updateRow(row)
- Executing: SelectLayerByAttribute maps NEW_SELECTION "map_name"='Airport'
- Start Time: Wed Jan 15 13:00:56 2014
- ERROR 000358: Invalid expression
- Cannot acquire a lock.
- Cannot acquire a lock.
- Failed to execute (SelectLayerByAttribute).
- Failed at Wed Jan 15 13:00:56 2014 (Elapsed Time: 0.00 seconds)
- count = int(arcpy.GetCount_management(ds).getCount(0))
- # treatment_maps_ds - this is the name of your input polygon dataset
- treatment_area_list = [row.map_name for row in arcpy.SearchCursor(treatment_maps_ds)]
- # point_ds - this is the name of your input point dataset
- arcpy.MakeFeatureLayer_management(point_ds, "ptslyr")
- arcpy.MakeFeatureLayer_management(treatment_map_ds, "treatmentlyr")
- # Loops through each treatment 'map_name'
- treatdict = {}
- for treatmap in treatment_area_list:
- arcpy.SelectLayerByAttribute_management("treatmentlyr", "NEW_SELECTION", "map_name = '" + str(treatmap) + "'")
- arcpy.SelectLayerByLocation_management("pntlyr", "INTERSECTS", "", "treatmentlyr")
- cnt = int(arcpy.GetCount_management("pntlyr").getOutput(0))
- treatdict[treatmap] = cnt
- cur,row = None, None
- cur = arcpy.UpdateCursor(treatment_maps_ds)
- for row in cur:
- cnt = treatdict[row.map_name]
- row.DI_Count = cnt
- cur.updateRow(row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement