# POS transect with measures posArray = arcpy.Array() for transit in dPOS.keys(): for mrk in dPOS[transit]: ta,tb = trans(mrk[0],mrk[1]) posArray.add(arcpy.Point(ta,tb,mrk[2],mrk[3])) rowPOS = curPOS.newRow() rowPOS.mark = transit.upper() rowPOS.plotid = plotid rowPOS.plotmark = plotid + transit.upper() rowPOS.shape = posArray curPOS.insertRow(rowPOS) posArray.removeAll()
# fillDonut.py # frequent forum request to fill holes # use an Update Cursor to edit polys with donuts # 22 May 2010 # Kim Ollivier kimo@ollivier.co.nz # (c) Creative Commons 3.0 (Attribution) # Method # ------ # Polygon features are stored as: # [[pnt,pnt,pnt,pnt,,pnt,pnt,pnt,pnt][pnt,pnt,pnt,pnt]] # Parts are separate lists inside the feature object array # null point in a part indicates donut ring(s) follow # So just step through and truncate at first null pnt per part, # re-assemble parts into a polygon # Update feature if a donut found, otherwise continue # Input is a layer so can use selection in Arcmap # could also put on menu at ArcMap 10 # can be back-ported to 9.3 # 4 June 2010 # added iter lambda function for part array because isn't interable # cleared polyOuter buffer earlier to fix logic for multiple parts import arcpy,sys def filldonut(inlay) : '''Edits a layer in-place fills all features with donuts requires a layer to honour selected features ''' desc = arcpy.Describe(inlay) shapefield = desc.ShapeFieldName rows = arcpy.UpdateCursor(inlay) n = 0 polyGeo = arcpy.Array() # to hold edited shape polyOuter = arcpy.Array() # to hold outer ring for row in rows: feat = row.getValue(shapefield) qInterior = False for partNum in range(feat.partCount) : part = feat.getPart(partNum) for pt in iter(lambda:part.next(),None) : # iter stops on null pt polyOuter.append(pt) if part.count > len(polyOuter) : qInterior = True polyGeo.append(polyOuter) # reassemble each part polyOuter.removeAll() # ready for next part if qInterior : # in any part of this feature, otherwise skip update n+=1 row.setValue(shapefield,polyGeo) rows.updateRow(row) polyGeo.removeAll() del rows,row msg = "Features with interior ring filled "+str(n) arcpy.AddMessage(msg) arcpy.AddMessage("Refresh view to see donuts disappear!") #---------------------------------------------------- if __name__ == '__main__' : inlay = sys.argv[1] # arcpy.GetParameterAsText(0) desc = arcpy.Describe(inlay) if desc.shapetype != 'Polygon' : arcpy.AddError(inlay + " Not a polygon class") else : filldonut(inlay) arcpy.RefreshGraphics()
... basically Calc field X to field M and Calc field Y to field Z.
import arcpy input_fc = r"C:\points_to_XYMZ\f.gdb\poly_fc_zm" g = arcpy.Geometry() geometry_list = arcpy.CopyFeatures_management(input_fc, g) for geom in geometry_list: c = geom.centroid print c.X, c.Y, c.Z, c.M
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.