6

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

  • 1
    I don't see why Fishnet is not working. Could you edt your post with your method using fishnet and what goes wrong with it ? – radouxju Sep 26 '14 at 20:53
  • Since the polygons are at different angles, I can't get the fishnet to match up with each polygon. (see picture above) – uniscorn Sep 26 '14 at 21:15
4

You could automate this approach with Python using the Create Fishnet (Data Management) tool. You can extract all of the pieces of the puzzle to do this analysis with python and then simply plug the pieces into the fishnet function. You need to start by iterating over all of the section polygons. Otherwise, you will get one large fishnet covering the entire sections extent.

  1. Use a SearchCursor with a SHAPE@XY token to iterate over the section polygons and get at the specific section vertices
  2. Use logic to find the ordinal coords. For example, nw_coord = max(y) AND min(x) etc
  3. Use SW coord to define origin
  4. Use NW coord to define y_axis_coord
  5. Use SE coord to define the corner_coord parameter
  6. Set number_rows to 4 and number_columns to 2
  7. Merge all of the newly created fishnet polygons
  8. Clip the merged fishnet polygons with the section boundaries
  • Thank you! I'm not the greatest at python but that makes sense. I'll try it. – uniscorn Sep 29 '14 at 13:11
8

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

  • Sorry to be dense, but I cannot for the life of me figure out why I'm getting error when I run your script: Runtime error Traceback (most recent call last): File "<string>", line 9, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy_init_.py", line 1234, in Describe return gp.describe(value) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\geoprocessing_base.py", line 374, in describe self._gp.Describe(*gp_fixargs(args, True))) IOError: "" does not exist >>> – uniscorn Oct 2 '14 at 14:34
  • The script above is a script tool to be run within ArcMap, collecting the paths for polyFC and outSections from the GUI. You can simply change the values of these variables to paths pointing to your input/output files. For example, polyFC = r'C:/somefolder/someshapefile.shp' – phloem Oct 2 '14 at 17:37
  • Yes I've changed the variables to my own, but still get the weird runtime error (see pic) - from what I've found when I searched it, it seems like maybe there was some error on install when we upgraded to 10.2. No time today to uninstall and reinstall everything, but will definitely give this a go when time allows. Thanks for the script! Way above my cognitive python abilities, but makes sense when I see it written out. – uniscorn Oct 2 '14 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.