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.
# 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()
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.