Cut and change attributes of polygon feature class based on parcel boundaries

554
3
05-27-2011 06:14 AM
EricHogan
New Contributor II
I am trying to create a tool within ArcMap that performs automated cuts on multiple city refuse service polygon feature classes simultaneously (instead of using manual processes to modify feature vertices or cutting features based on sketching).  The boundaries of the cut are defined through selecting a parcel based on the user manually typing the parcel ID into the tool's window. Then, the user may check a box to delete the newly-cut features or, for each layer, they may select attribute values from scroll down lists for "Unit_Code" and "Unit_Name" (8 total) or let the attributes default on the old values. Cut features will remain in the original feature class rather than being sent to a new one. 

Some problems I am having include how I should code "Cut Polygon Features" in python and how I should use parameters to allow me the options for drop-down lists, entry fields, and check boxes in my tools window. 

Thoughts?
Tags (2)
0 Kudos
3 Replies
curtvprice
MVP Esteemed Contributor
Some problems I am having include how I should code "Cut Polygon Features" in python and how I should use parameters to allow me the options for drop-down lists, entry fields, and check boxes in my tools window. 


It's a little unclear to me what you are trying to do (for example, how you delineate a boundary using existing polygons, this sounds more like a dissolve operation than a "cut polygons" operation).

But I would look into script tool parameter validation, which allows you to populate pick lists, checkboxes etc. based on the input parameters:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00150000000t000000.htm
0 Kudos
KimOllivier
Occasional Contributor III
I started a similar project to create a tool that split a parcel in half if there were two address points in the parcel, when the parcel was a corner property. It needed ET_Geotools

I created a line for the split by bisecting the two points and used that to intersect the polygon. You can then write the split polygon back to the featureclass.

# bisect2
# bisect a parcel into two
# between two points inside
# extend to multipoints later
# input parcel_id
# select parcel poly
# select address points
# if two points
# calculate perpendicular bisector
# cut polygon with the line
# save to be replaced
# 26 Nov 2010
# 
import arcgisscripting,sys,os,math
gp = arcgisscripting.create(9.3)

def createknife(par_id):
    """create knife lines for bulk splitting
    using address points with same parcel_id"""
    gp.MakeFeatureLayer_management(fcAdd,"add_lay","parcel_id = "+str(par_id))
    shapeField = gp.Describe(fcAdd).shapeFieldName
    cur = gp.SearchCursor("add_lay","parcel_id = "+str(par_id),SR)
    row = cur.next()
    n = 0
    pt = []
    while row:
        pt.append(row.getValue(shapeField).centroid)
        n+=1
        row = cur.next()
    del row,cur
    ## print n, "points"
    ##for addpt in pt:
    ##    print "address ",addpt.X,addpt.Y  
    # find mid point and angle, add 90 degrees
    midpt = gp.CreateObject("Point")
    midpt.X = (pt[0].X + pt[1].X)/2.0
    midpt.Y = (pt[0].Y + pt[1].Y)/2.0
    radAngle = math.atan2(pt[0].Y - pt[1].Y,pt[0].X - pt[1].X) + math.pi/2.0
    # print "midpoint",midpt.X,midpt.Y,"Bearing",radAngle
    # create a perpendicular line in a temp fc
    ext = gp.Describe("in_memory/parcel").extent
    size = max(ext.width,ext.height)*1.5
    print par_id,size
    pnt1 = gp.CreateObject("Point")
    pnt2 = gp.CreateObject("Point")
    pnt1.X = midpt.X - size * math.cos(radAngle)
    pnt1.Y = midpt.Y - size * math.sin(radAngle)
    pnt2.X = midpt.X + size * math.cos(radAngle)
    pnt2.Y = midpt.Y + size * math.sin(radAngle)
    pline = gp.CreateObject("Array")
    pline.Add(pnt1)
    pline.Add(pnt2)
    ##print "knife    %8.1f %8.1f %8.1f %8.1f" % (pnt1.x,pnt1.y,pnt2.x,pnt2.y)
    cur = gp.InsertCursor("in_memory/knife")
    row = cur.newRow()
    row.shape = pline
    cur.insertRow(row)
    row = cur.newRow()
    pline.removeAll()
    del cur,row
    # temp debugging 
    outLine = gp.CreateScratchName("split_line","","FeatureClass")
    gp.CopyFeatures_management("in_memory/knife",outLine)
    ##print "Knife   extent",gp.Describe("in_memory/temp").extent
    ##print "Parcel  extent",gp.Describe("in_memory/parcel").extent
    ##print "Address extent",gp.Describe("add_lay").extent
    ##outAdd = gp.CreateScratchName("split_add","","FeatureClass")
    ##gp.CopyFeatures_management("add_lay",outAdd)

    gp.AddToolbox(r"C:\Program Files\ET SpatialTechniques\ET GeoWizards 10.0 for ArcGIS 9.2 and 9.3\ET GeoWizards.tbx")

    outParcel = "in_memory/split" #gp.CreateScratchName("split_parcel","","FeatureClass")
    gp.ET_GPPartitionPolygons("in_memory/parcel","in_memory/temp",outParcel)
    # print gp.GetMessages()
    return outParcel

# -------------------- main -----------------------
try:
    fcPar = sys.argv[1]
except:
    fcPar = "corner"
gp.overwriteOutput = True
ws = "d:/work/pcl/CourierRun.gdb"
gp.workspace = ws
fcAdd = "addrun"
SR = gp.CreateObject("SpatialReference")
SR.CreateFromFile("c:/arcgis/nztm.prj")
gp.CreateFeatureClass("in_memory","knife","Polyline","","","",SR)
rCursor = gp.SearchCursor(fcPar)
row = rCursor.next()
while row:
    par_id = row.par_id
    result = split(par_id)
    
    row = rCursor.next()
0 Kudos
EricHogan
New Contributor II
Kim:
Is the parcel itself being split into two?  I want to avoid doing that since I am only using that as a reference for my refuse feature class to be cut.  I basically want to take a parcel that is specified by the the user by typing the parcelID value, then using the selected parcel as a cookie cutter to seperate out that portion of the feature class so that it is its own feature (or becomes an additional part of a multi-part feature) within that feature class.  Unlike clipping, I want to avoid copying the selected feature to a new feature class of its own.
--------------------------------------------------

Curtis:

This is the manual version of my process that I wish to automate:
--Select the specific feature(s) within the feature class (SelectByAttributes: "UNIT_CODE = TUES")
--Explode (multi to single-part) the selected features,
--use "Cut Polygon Features" in the Edit Task menu,
--use the sketch tool to click on each vertex of the parcel (using snapping),
--finish the feature,
--unselect the features, then
--click on the newly created feature,and zoom to it
   (to insure only the area within the sketch will be edited)
--either
       1)go into the attibute table to edit the refuse information
                    (ex. change collection day from TUES to THUR)
       2)press delete to remove the service entirely
                    (ex. for a parcel with a commercial address)

That is pretty much my exact process for editing refuse data (based on the the boundaries of parcels), so hopefully this more clearly describes what I am trying to acheive through automation of an otherwise potentially lengthy manual process. 

Because I am not quite sure what "Cut Polygon Features" is behind the scenes (the python code, etc.) it is hard for me to describe what is going on beyond me going through these steps in ArcMap.  This lack of understanding of what it means to "cut" a feature is the source of my problem.  Are there alternatives to using "Cut Polygon Features" that allow someone to specify an area inside a feature class, and edit only the attributes the boudaries of the selection?
0 Kudos