# Modifying parameters in Subdivide Polygon to obtain value from attribute table

I want to split polygons in half, like if a building were split by its roof ridge. I've somehow managed to obtain this in model builder by doing calculations on geometry statistics but as the input data might consist of 50,000+ polygons it's clunky and slow.

There's a tool in ArcGIS Pro, Subdivide Polygons, which is far more faster and would have given the desirable output. If it would only have allowed to use attribute values as an input for Split angle but instead you have to define a fixed value, which would be 0 in the snippet below.

I'm really a beginner at python, but would there be a way to modify the parameter so that it obtains the value from the attribute table rather than using a fixed value?

``````import arcpy

arcpy.env.workspace = r"C:/data/project.gdb"
arcpy.SubdividePolygon_management(
"studyarea", "subdivisions", "NUMBER_OF_EQUAL_PARTS", 10, "", "", 0,
"STRIPS")
``````
• Yes that fairly easy to replace your zero with a variable that changes value. Search the help file for searchcursor and explore the code snippets at the bottom of the help page. Jun 9 at 9:22
• How complex are polygons? Single part? Have holes? Jun 9 at 9:27
• Thanks! Mostly rectangles, single part without holes. Jun 9 at 9:31

I am running ArcGIS 10.8, but I cannot find subdivide polygon tool. Anyway, the idea is to rotate original polygons around centroid (so you can use same rotation angle in subdivide tool) and un-rotate results after. So, I used 2 tools, - add geometry attributes to compute centroid coordinates and minimum bounding geometry to calculate polygon orientation:

I ran this on field Shape of the copy(!) of originals:

``````from math import sin, cos
def RotateLine(x0,y0, shp,a):
part=shp.getPart(0)
ar=arcpy.Array()
for i in range(len(part)):
p=part.getObject(i)
x,y = p.X-x0, p.Y-y0
xN=cos(a)*x+sin(a)*y
yN=-sin(a)*x+cos(a)*y
pN=arcpy.Point(xN+x0,yN+y0)
lineRotated=arcpy.Polygon(ar)
return lineRotated
``````

#-----------------------

``````RotateLine( !INSIDE_X!, !INSIDE_Y!, !Shape!, !MBG_Orientation! )
``````

I used my own procedure, to split polygon and un-rotated results:

``````RotateLine( !INSIDE_X!, !INSIDE_Y!, !Shape!, -!MBG_Orientation! )
``````

Note minus in above!

Output: 