[GIS] Automate Splitting Polygons Into Sections

arcgis-desktopeditingpolygon

I need to split many cemetery sections into 8 (mostly) equal pieces each. Each section is for the most part square, but there are a few odd shapes too. And the squares are not all the same size.

Is there a way to automate this process at all, or is doing it manually my only option?

Fishnet option doesn't work, and I really can't find anything else to try. Each polygon would be split at the midpoint so I'm thinking there must be some way to save a little time.

(edited for clearer picture)

Cemetery polygons - sections

Fishnet - Different angles of polygons.

python error

Best Answer

Here is a method using arcpy geometry objects. The script creates a rotated hull rectangle around each polygon, splits it into plots, and clips the plots to the original polygon. As Aaron mentions, you could likely achieve this with the fishnet tool, but I could not figure out how to (in Step #2) "use logic to find the ordinal coords" for rotated polygons.

The script:

# import libraries
import arcpy

# set input/output parameters
polyFC = arcpy.GetParameterAsText(0)        # input polygons
# standalone: polyFC = r'C:/somefolder/someshapefile.shp'
outSections = arcpy.GetParameterAsText(1)   # output section polygons
# standalone: outSections = r'C:/somefolder/someshapefile.shp'

# establish spatial reference
desc = arcpy.Describe(polyFC)
SR = desc.spatialReference

# lines container
Lines = []

for row in arcpy.da.SearchCursor(polyFC, ["SHAPE@"]):
    # create hull rectangle to establish a rotated area of interest
    coordSplit = row[0].hullRectangle.split(' ')

    # collect corner coordinates
    coordList = arcpy.Array([arcpy.Point(coordSplit[0],coordSplit[1]),arcpy.Point(coordSplit[2],coordSplit[3]),arcpy.Point(coordSplit[4],coordSplit[5]),arcpy.Point(coordSplit[6],coordSplit[7]),arcpy.Point(coordSplit[0],coordSplit[1])])

    # create lines from hull rectangle
    currentLines = []
    for pointNum in range(0,4):
        arcpy.Array([coordList.getObject(pointNum),coordList.getObject(pointNum+1)])
        hullRecLine = arcpy.Polyline(arcpy.Array([coordList.getObject(pointNum),coordList.getObject(pointNum+1)]))
        currentLines.append(hullRecLine)

    # compare first and second line to determine if first line is short or long
    firstLong = 0
    if currentLines[0].length > currentLines[1].length:
        firstLong = 1

    # determine how far apart to split lines
    longLineSpace = currentLines[firstLong].length/4
    shortLineSpace = currentLines[firstLong + 1].length/2

    # join points to create parallel lines
    for point in range(1,4):
        longPoint1 = currentLines[firstLong].positionAlongLine(longLineSpace*point)
        longPoint2 = currentLines[firstLong + 2].positionAlongLine(currentLines[firstLong + 2].length - (longLineSpace*point))
        longLine = arcpy.Polyline(arcpy.Array([longPoint1.centroid,longPoint2.centroid]), SR)

        # clip lines to original polygon
        longLineClip = longLine.intersect(row[0],2)
        # add to array
        Lines.append(longLineClip)

    shortPoint1 = currentLines[firstLong + 1].positionAlongLine(shortLineSpace)
    shortPoint2 = currentLines[firstLong - 1].positionAlongLine(currentLines[firstLong - 1].length - (shortLineSpace))
    shortLine = arcpy.Polyline(arcpy.Array([shortPoint1.centroid,shortPoint2.centroid]), SR)

    # clip to original polygon
    shortLineClip = shortLine.intersect(row[0],2)
    # add to array
    Lines.append(shortLineClip)

# write geometries to disk
arcpy.CopyFeatures_management(Lines, outSections)

# add to map
mxd = arcpy.mapping.MapDocument("CURRENT")
dataFrame = arcpy.mapping.ListDataFrames(mxd, "*")[0]
addLayer = arcpy.mapping.Layer(outSections)
arcpy.mapping.AddLayer(dataFrame, addLayer)

del row

And the output: enter image description here