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.
<SPAN class="comment token"># Import the Arcpy Module</SPAN>
<SPAN class="keyword token">import</SPAN> arcinfo
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">from</SPAN> arcpy <SPAN class="keyword token">import</SPAN> env
<SPAN class="comment token"># Set up the working Environment</SPAN>
env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"D:\Travis\Personal\Geoff\Nantucket\Zoning\Backlots\Backlots.gdb"</SPAN>
env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token">#Variables</SPAN>
Parcels <SPAN class="operator token">=</SPAN> <SPAN class="string token">"R40_80000sqft"</SPAN>
Street_Center <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ROAD_CL_2017_12"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>Parcels<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"Parcels_lyr"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>Street_Center<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"Street_Lyr"</SPAN><SPAN class="punctuation token">)</SPAN>
Street_Lyr <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Street_Lyr"</SPAN>
Parcels_lyr <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Parcels_Lyr"</SPAN>
<SPAN class="comment token">#Add a field to parcels to be populated with building area</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddField_management<SPAN class="punctuation token">(</SPAN>Parcels<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"Frontage"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"DOUBLE"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Buffer Street Center Lines</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>Buffer_analysis<SPAN class="punctuation token">(</SPAN>Street_Lyr<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"Street_Buff"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"40 Feet"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"FULL"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"ROUND"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"ALL"</SPAN><SPAN class="punctuation token">)</SPAN>
Street_Buff <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Street_Buff"</SPAN>
<SPAN class="comment token">#Convert parcel layer polygons to lines</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>PolygonToLine_management<SPAN class="punctuation token">(</SPAN>Parcels_lyr<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"R40_PolyToLine"</SPAN><SPAN class="punctuation token">)</SPAN>
R40_Line <SPAN class="operator token">=</SPAN> <SPAN class="string token">"R40_PolyToLine"</SPAN>
<SPAN class="comment token">#Convert parcel lines to a layer for use in select by location</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>R40_Line<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"R40_Line_Lyr"</SPAN><SPAN class="punctuation token">)</SPAN>
R40_Line_Lyr <SPAN class="operator token">=</SPAN> <SPAN class="string token">"R40_Line_Lyr"</SPAN>
<SPAN class="comment token">#Create a cursor to select all parcel lines that fall within the street buffer</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>Parcels_lyr<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'Shape@'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'Frontage'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> linecursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> linerow <SPAN class="keyword token">in</SPAN> linecursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token">#get the geometry to use in the spatial selection</SPAN>
geom <SPAN class="operator token">=</SPAN> linerow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token">#select parcel lines from the street buffer using the geom variable</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByLocation_management<SPAN class="punctuation token">(</SPAN>R40_Line_Lyr<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"COMPLETELY_WITHIN"</SPAN><SPAN class="punctuation token">,</SPAN> Street_Buff<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NEW_SELECTION"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#get the Length of the selected features and sum</SPAN>
lengthsum <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>R40_Line_Lyr<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'SHAPE@LENGTH'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> newcursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> newrow <SPAN class="keyword token">in</SPAN> newcursor<SPAN class="punctuation token">:</SPAN>
lengthsum <SPAN class="operator token">=</SPAN> lengthsum <SPAN class="operator token">+</SPAN> newrow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">print</SPAN> lengthsum
<SPAN class="keyword token">del</SPAN> newcursor
parcelrow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="operator token">=</SPAN> lengthsum
<SPAN class="keyword token">if</SPAN> lengthsum <SPAN class="operator token">!=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN>
parcelrow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> lengthsum
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
parcelrow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
linecursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>linerow<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">del</SPAN> linecursor<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>