1

I want to split a polygon into two equal parts but I want from a specific point to the polygon dividing line.

How to do this using ArcGIS Desktop 10?

  • 1
    This is a nice task for scripting. Are you open for this approach? – FelixIP May 2 '16 at 0:17
  • 2
    I think you should include a picture in your question. – PolyGeo May 2 '16 at 1:07
2

For that you need to

  • find another point on the polygon outline (with reasonable accuracy, that is set to 0.01 m in below script)
  • connect 2 points by line
  • split polygon using this line

INPUT:

enter image description here

OUTPUT:

enter image description here

To make script below work, you’ll need to put three layers listed from the top down in your mxd table of content:

  • empty polygon layer to store splitted parts
  • point layer with single point
  • source polygon layer

Note: Point has to be snapped to or sit outside of polygon boundary

import arcpy, traceback, os, sys
gr=(math.sqrt(5)-1)/2

try:
    def showPyMessage():
        arcpy.AddMessage(str(time.ctime()) + " - " + message)
    #golden section to find minimum
    def gss(a,b,tol):
        c=b-gr*(b-a)
        d=a+gr*(b-a)
        fc=f(c);fd=f(d)
        while abs(c-d)>tol:
            if fc<fd:
                b,d,fd=d,c,fc
                c=b-gr*(b-a)
                fc=f(c)
            else:
                a,c,fc=c,d,fd
                d=a+gr*(b-a)
                fd=f(d)
        return (b+a)/2
    def f(z):
        global two
        theP=outline.positionAlongLine (z).firstPoint
        splitter=arcpy.Polyline(arcpy.Array([point,theP]),SR)
        two=pgon.cut(splitter)
        intR=abs(two[0].area-two[1].area)/pgon.area*100
        arcpy.AddMessage(intR)
        return intR

    mxd = arcpy.mapping.MapDocument("CURRENT")
    layers = arcpy.mapping.ListLayers(mxd)
    (outputLR,pointLR,pgonLR) =layers[:3]
    g=arcpy.Geometry()
    point=arcpy.CopyFeatures_management(pointLR,g)[0].firstPoint
    SR = arcpy.Describe(pointLR).spatialReference
    pgon=arcpy.CopyFeatures_management(pgonLR,g)[0]
    outline=pgon.boundary();L=outline.length
    chainage=gss(0,L,0.01)
    doit=f(chainage)

    curT = arcpy.da.InsertCursor(outputLR,"Shape@")
    for item in two:
        curT.insertRow((item,))


except:
    message = "\n*** PYTHON ERRORS *** "; showPyMessage()
    message = "Python Traceback Info: " + traceback.format_tb(sys.exc_info()[2])[0]; showPyMessage()
    message = "Python Error Info: " +  str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"; showPyMessage()            

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.