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"
    "studyarea", "subdivisions", "NUMBER_OF_EQUAL_PARTS", 10, "", "", 0, 
New contributor
user186831 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 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. – Hornbydd Jun 9 at 9:22
  • How complex are polygons? Single part? Have holes? – FelixIP Jun 9 at 9:27
  • Thanks! Mostly rectangles, single part without holes. – user186831 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:

enter image description here enter image description here

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

from math import sin, cos
def RotateLine(x0,y0, shp,a):
  a=  math.radians(a)
  for i in range(len(part)):
    x,y = p.X-x0, p.Y-y0
  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!


enter image description here

Your Answer

user186831 is a new contributor. Be nice, and check out our Code of Conduct.

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.