I'm trying to calculate the accumulative street length in various jurisdictions in a county. To do this I'm using a search cursor in the city layer and then using the current feature to select streets by location and then sum up the total shape length for that selection and print out the city name and associated shape length. I'm getting an error that ESRI states is due to path name, unsupported type, or data type does not work for this tool. I pasted the path right out of catalog, the city layer is a polygon, the streets are polylines. Here is my code so far:
import arcpy
places = r"C:\Users\jsobryan\Desktop\ArcMap\Scrap.gdb\City_Township_Unincorp"
streets = r"C:\Users\jsobryan\Desktop\ArcMap\Scrap.gdb\Streets"
arcpy.MakeFeatureLayer_management(streets,"lyr")
with arcpy.da.SearchCursor(places,["DIST_NAME"]) as cursor:
for row in cursor:
arcpy.SelectLayerByLocation_management("lyr","HAVE_THEIR_CENTER_IN",row[0],"","NEW_SELECTION")
sum = arcpy.Statistics_analysis("lyr",r"C:\Users\jsobryan\Desktop\ArcMap\Scrap.gdb\table_1",[["Shape.STLength()","SUM"]])
print row[0] + ": " + sum
Here is the error:
ERROR 000732: Selecting Features: Dataset CITY OF ANYWHERE_USA does not exist or is not supported
Thinking maybe I need to do a make feature layer for cities and and use search cursor to select row and then opt to use selected features in select layer by location parms?
DIST_NAME
, an attribute field. SLBL wants geometry to select against.