theFeatureList = [ [59.9359664290001, 58.2873293230001], [59.9354474180001, 58.292897049], [59.9359664290001, 58.2873293230001], [15.7361337040001, 69.5741156380001], [5.46961326000007, 74.605524862], [21.6743239320001, 90.0000000000001], [61.6145099540001, 90.0000000000001], [74.588779291, 78.7328713650001], [74.9956238680001, 62.052243682], [59.9359664290001, 58.2873293230001], [29.5877337620001, 75.2087581980001], [29.5902670670001, 75.2091884760001], [29.5877337620001, 75.2087581980001] ]
you want: this
Ha, now I see it. It's hard to read unformatted.So, it looks like you initially get an array of x,y values for the first part of the polygon with this:for pnt in inShape.getPart(polyIndex):Now you need to pull the the individual points from the array that is the first part of the first polygon record in your feature class. Think of multipart features.
I don't see where 'pnt' is defined, so it can't have an attribute 'X'.
import arcpy, os dist = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data\glink_seismic_Buffer_ClipExample.shp" origin = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data\section_for_clipping_disturbance_features.shp" sqrs = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data\sections_analysis.shp" outfolder = r"N:\Projects\120802 CEMA Landscape Simulation Modelling for RMWB\05- Data" outpoly = r"seismic_tile_example.shp" try: arcpy.Delete_management(outfolder + "/" + outpoly) except: pass arcpy.CreateFeatureclass_management(outfolder, outpoly, "POLYGON", "", "", "", dist) distdesc = arcpy.Describe(dist) distshapefieldname = distdesc.ShapeFieldName squaredesc = arcpy.Describe(sqrs) squareshapefieldname = squaredesc.ShapeFieldName originpoly = arcpy.SearchCursor(origin) squares = arcpy.SearchCursor(sqrs) inRows = arcpy.SearchCursor(dist) outRows = arcpy.InsertCursor(outfolder + "/" + outpoly) polyarray = arcpy.Array() origindesc = arcpy.Describe(origin) originshapefieldname = origindesc.ShapeFieldName orig = originpoly.next() originvalue = orig.getValue(originshapefieldname) origincentroid = originvalue.centroid for square in squares: squarevalue = square.getValue(squareshapefieldname) squarecentroid = squarevalue.centroid xoffset = squarecentroid.X - origincentroid.X yoffset = squarecentroid.Y - origincentroid.Y polyIndex = 0 for inRow in inRows: inShape = inRow.shape pntObj = arcpy.Point() arrayObj = arcpy.Array() for pnt in inShape.getPart(polyIndex): pntObj.ID = polyIndex pntObj.X = pnt.X + xoffset pntObj.Y = pnt.Y + yoffset arrayObj.add(pntObj) outShape = outRows.newRow() outShape.shape = arrayObj outRows.insertRow(outShape) polyIndex += 1
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.