I currently have a code that is performing most of what i want it to do but I need to associate summed values with the corresponding parcels. Right now I believe the code is giving me the sum of all frontage that falls within a buffer area. I need to figure out how to sum each of the lines that make up individual parcels, sum them and add them to a field in the parcel layer.
# Import the Arcpy Module
from arcpy import env
# Set up the working Environment
env.workspace = r"D:\Travis\Personal\Geoff\Nantucket\Zoning\Backlots\Backlots.gdb"
env.overwriteOutput = True
Parcels = "R40_80000sqft"
Street_Center = "ROAD_CL_2017_12"
Street_Lyr = "Street_Lyr"
Parcels_lyr = "Parcels_Lyr"
#Add a field to parcels to be populated with building area
# Buffer Street Center Lines
Street_Buff = "Street_Buff"
#Convert parcel layer polygons to lines
R40_Line = "R40_PolyToLine"
#Convert parcel lines to a layer for use in select by location
R40_Line_Lyr = "R40_Line_Lyr"
#Create a cursor to select all parcel lines that fall within the street buffer
with arcpy.da.UpdateCursor(Parcels_lyr, ['Shape@','Frontage']) as linecursor:
for linerow in linecursor:
#get the geometry to use in the spatial selection
geom = linerow
#select parcel lines from the street buffer using the geom variable
arcpy.SelectLayerByLocation_management(R40_Line_Lyr, "COMPLETELY_WITHIN", Street_Buff, "", "NEW_SELECTION")
#get the Length of the selected features and sum
lengthsum = 0
with arcpy.da.SearchCursor(R40_Line_Lyr,['SHAPE@LENGTH']) as newcursor:
for newrow in newcursor:
lengthsum = lengthsum + newrow
if lengthsum != 0:
parcelrow = lengthsum
parcelrow = 0