Select to view content in your preferred language

Split polygon

1452
3
09-28-2011 06:25 AM
CaseyBentz
Frequent Contributor
I am looking for a way to split a polygon envelope into 4 equal size pieces.  I have used the Feature Envelope to Polygon GP tool, I then added fields to get the mid x and mid y of the envelope.  Now, I want to split that polygon into 4 pieces.  Does anyone know how to do this?

Casey
Tags (2)
0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor
I would recommend using the 'Create Fishnet' tool to create a polygon envelope of 4 equal pieces.  You can use a feature class as the extent and then simply specify the number of columns and rows.
0 Kudos
CaseyBentz
Frequent Contributor
Thanks Jake.

I have just stumbled onto this tool myself.  I have a feature class of hundreds of polygons and I want this for each one.  I have tried using it in a Model using Make Feature Layer for each one of my polygons and it does not appear to respect the geometry of feature layer but the geometry of the feature class.  Any ideas?  I have resorted to exporting each feature to its own feature class.
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi Casey,

I was able to get this to work with the following code.  It will loop through each feature in a feature class and create a 2x2 fishnet for each feature.

import arcpy
from arcpy import env
env.workspace = r"C:\temp\python\test.gdb"
env.overwriteOutput = True

fc = "Airports"

rows = arcpy.SearchCursor(fc)
for row in rows:
    x = row.OBJECTID
    arcpy.MakeFeatureLayer_management(fc, "fc_lyr", "OBJECTID = " + str(x))
    rows2 = arcpy.SearchCursor("fc_lyr")
    for row2 in rows2:
        XMIN = row2.shape.extent.XMin
        YMIN = row2.shape.extent.YMin
        XMAX = row2.shape.extent.XMax
        YMAX = row2.shape.extent.YMax
        YMIN2 = row2.shape.extent.YMin + 10
        orig_coord = str(XMIN) + " " + str(YMIN)
        y_axis = str(XMIN) + " " + str(YMIN2)
        corner_coord = str(XMAX) + " " + str(YMAX)
        arcpy.CreateFishnet_management("Fishnet_" + str(x), orig_coord, y_axis, "0", "0", "2", "2", corner_coord, "NO_LABELS", "", "POLYGON")

del row, rows, row2, rows2  
0 Kudos