# Calculating length of polygon in ArcGIS Desktop?

My company has electric lines that go through people's yards. The areas around these lines require trimming occasionally, which necessitates acquiring easements on some properties. See attached image for an example of a work area.

I am trying to automate a process to measure a polygon or polyline (the main electric line) that crosses multiple polygons (parcels) so we can request a specific length of easement when necessary. Our current process involves creating a new polyline layer and making a new segment for the frontage of each property so the length is automatically calculated. However, this is a very slow and tedious process, as we have tens of thousands of parcels with main line.

I've tried converting the parcels polygon to lines (Feature to Line tool) and labeling based on length. However, the parcels layer is from the county, and it's pretty messy, especially in rural/non-regular areas (not visible on my attached screenshot). There are a lot of extra vertices and line segments that get pulled into the new line layer which confound the length measurements with this method. I've tried simplifying polygons to reduce/remove these extras, but simplifying too much will alter the shape of the parcel and many extraneous portions still seem to transfer over.

I've also tried buffering around the main electric line to create a polygon, then using the Identity tool with the parcels layer to split it based on property divisions. My thought was to create polygons that spanned the front of peoples' properties, then measure the length of those new polygons (we aren't concerned about width here, since that varies based on local ordinances, so it's calculated later). This produced a length field, but its values aren't even close to the actual length of each polygon.

However, I've been unable to find a way to automate the measuring of polygon length. Minimum Bounding Geometry hasn't been helpful.

Is there a script I could use or a tool that I'm missing that could simplify this process of finding the length of a polygon?

• Did you try converting parcel lines to polygons first? Use it as a clip to solve 50% of the cases. This will help with the rest. Jul 9, 2018 at 18:38
• Hi Felix, yes I have been using the parcels as a polygon layer. I didn't show it in my attached image, but I have clipped my output to show just the intersections with parcels. I think Chris's answer below is a really good solution - thanks for taking a look! Jul 10, 2018 at 15:15

I am assuming that you only need an easement when a powerline crosses a parcel, and that the length of that easement is equal to the length of the line that crosses the parcel. If that's the case, you can use an `intersect`, based on the parcel polygons and the electric line polyline. An intersect with a polygon and polyline with result in a polyline feature class, with the attributes from the polygon copied to the polyline. Assuming each parcel has an ID field, which we will call `parcel_id`, you can use a script like this to automate the process:

``````import arcpy
import collections as c

# Define variables
parcel_fc = r"C:\easements.gdb\parcels"
powerline_fc = r"C:\easements.gdb\powerlines"
result = r"C:\easements.gdb\easement_lengths"
result_table = r"C:\easement_lengths.csv"
result_dict = c.defaultdict(float)  # a special type of dictionary in which values don't need to be initialized

#  Do the intersect, keeping only sections of line that cross parcels
arcpy.Intersect_analysis([parcel_fc, powerline_fc], result)

#  Get lengths from intersected lines
with arcpy.da.SearchCursor(result, ["parcel_id", "SHAPE@"]) as cursor:
for row in cursor:
result_dict[row[0]] += row[1].length  # Using a default dict here in case there are times when more than one line crosses the same parcel
#  Note that .length is a property of the arcpy geometry class

# Write lengths to a file that can be opened in excel
with open(result_table, 'w') as f:
for parcel in result_dict:
f.write("{}, {}\r\n".format(str(parcel), str(result_dict[parcel])))
``````

NOTE: This will only work as intended if electric line feature class is a polyline. If the result of the intersect is a polygon, the .length will return the perimeter, not the length.

I would recommend setting the result of the intersect to go into a geodatabase (make a feature class rather than a shapefile) before calculating lengths, though I don't think it's absolutely necessary.

• Thanks Chris!! This is very helpful. I've shared this with my coworkers and I think it could be adapted for what we want. Do you know if it's possible to add a buffer around the line for the intersect? Not like the tool Buffer, but like a range near the polyline that the intersect will detect? I realize that might be a bit much to hope for but I thought I'd ask just in case. Jul 10, 2018 at 15:19
• Glad this was helpful! If this answered your question, could you please mark the question as answered? It sounds like you are talking about a gradient-based buffer, in which the impact decreases as you move away from the source. If so, you could use the Euclidean Distance tool, and then do Zonal Statistics using your parcel shapefile. This would be a second operation. Otherwise, a normal vector-based buffer can be used with a second intersect to calculate area.
– Matt
Jul 10, 2018 at 15:55