Split polygon feature by percentage

15091
19
08-11-2016 06:49 AM
JayantaPoddar
MVP Esteemed Contributor

Hi friends,

I have a feature table with a field (Float) containing percentage values which aggregates to 100%. And I have one big polygon. I need to split the polygon based on the percentage values from the table.

I have seen a similar tool in ET's GeoTools.

http://www.ian.ko.com/ET_GeoTools/UserGuide/ETSplitPolygonByArea.htm

But I don't have the tool.

Is there any workaround in ArcGIS? Maybe using Python?



Think Location
0 Kudos
19 Replies
by Anonymous User
Not applicable
JayantaPoddar
MVP Esteemed Contributor

Hello Avinash,

Thanks for your quick response. The above tools you mentioned, splits the polygon feature parts from the feature class and exports them to different feature classes.

My case is a little different. My polygon feature class has only one polygon (01 record). And the splitting should be based on the percentage values from another GDB table.

An example of resulting polygon is attached (ET GeoTools used in this case).

Let me know if you have any further suggestion.



Think Location
0 Kudos
by Anonymous User
Not applicable

Hello Jayanta,

Looks like you have one polygon and another one is feature or one table with % values.

If both are features, then overlay works and for another I need to test in my system.

Let you know my findings.

can you please give me yours sample files.

Thanks

0 Kudos
JayantaPoddar
MVP Esteemed Contributor

Second one is a table.

You can create a sample as below.

Create any random polygon (with UTM/WGS_1984 projection).

And a table with 4 records where a field <Field_Per> will have values of say 20, 35, 15, 30 for the four records.

Thanks again for your efforts.



Think Location
0 Kudos
WesMiller
Regular Contributor III
JayantaPoddar
MVP Esteemed Contributor

Hi Wes,

Thank you for sharing the link. But my problem is different. The polygon needs to be split into variable sizes (area) based on the percentage value from another table.



Think Location
0 Kudos
FC_Basson
MVP Regular Contributor

You can try this script.  I'm not familiar with the ET-Geotools version, but I think it does more or less the same.  It adds the split parts to the existing polygon layer, but you can change it to write to a new feature class.

import arcpy

mxd = arcpy.mapping.MapDocument('CURRENT')
df = mxd.activeDataFrame
layers = arcpy.mapping.ListLayers(df)
# select layer - my known polygon layer with only one polygon
poly = layers[2]
# split steps
splits = [20, 30, 50]


# get polygon and extent properties
with arcpy.da.SearchCursor(poly, ["SHAPE@"]) as pcursor:
   for prow in pcursor:
      polygon = prow[0]    # polygon to cut
      e = polygon.extent   # bounding extent of polygon
      print e.XMin,e.YMin,e.XMax,e.YMax
del pcursor


# geometric cut test iteration step size - modify value to get better accuracy
stepsize = 0.001
# set parameters to move from left to right over the polygon
leftXstart = e.XMin
leftX = e.XMin + stepsize
ymax = e.YMax
ymin = e.YMin

cutpoly = polygon
icursor = arcpy.da.InsertCursor(poly, ["SHAPE@"])
# iterate cut percentage list
for i in splits[:2]:
   print i
   tol = 0
   while tol < i:
      # construct NS line
      pntarray = arcpy.Array()
      pntarray.add(arcpy.Point(leftX, ymax))
      pntarray.add(arcpy.Point(leftX, ymin))
      pline = arcpy.Polyline(pntarray,arcpy.SpatialReference(4326))    
      # cut polygon and get split-parts
      cutlist = cutpoly.cut(pline)
      tol = 100 * cutlist[1].area / polygon.area      
      leftX += stepsize
      #print str(leftX) + ":" + str(tol)
   cutpoly = cutlist[0]
   # part 0 is on the right side and part 1 is on the left side of the cut
   icursor.insertRow([cutlist[1]])
# insert last cut remainder
icursor.insertRow([cutlist[0]])
del icursor

This is the result for cutting the polygon into 20%, 30% and 50%

JacobSiech1
New Contributor III

Hi FC Basson,

I wanted to know if you could help me with your script that you have.  It does not want to run for me.  It gets to line 13 and says, " with arcpy.da.SearchCursor(poly, ["SHAPE@"]) as pcursor: TypeError: 'in_table' is not a table or a featureclass" do you know what might be causing this? 

Thanks,

~J~S~

0 Kudos
JacobSiech1
New Contributor III

Hi again,

I fixed the last issue but now have another.  This is the error that comes up:

Traceback (most recent call last):
File "C:\Users\jacob.siech\Desktop\TestScript.py", line 42, in <module>
cutlist = cutpoly.cut(pline)
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\arcobjects\arcobjects.py", line 859, in cut
return convertArcObjectToPythonObject(self._arc_object.Cut(*gp_fixargs((other,))))
RuntimeError: All geometries involved in this operation must have the same spatial reference.

I have checked the spatial reference of the data fraim and the layer and they are the same.  So I do not know what to do now.  Any help would be great.

Thanks,

~J~S~

0 Kudos