Good Morning
I am trying to rotate feature class with over 700 polygons based on the angle in an attribute? These polygons are all based on center points that were buffered and then run the create envelope tool. All the polygons now are oriented N/S. Any wok flows would be appreciated.
Thanks
Bruce Burwell
If you are going to share someone else's code verbatim, giving a reference and attribution will prevent others from thinking you are plagiarizing work.
Rotating polygons by value from attribute table using ArcPy? - Geographic Information Systems Stack Exchange
This throws a NoneType is not iterable error.
Hi Anyry,
Here is the solution
Step 1: Polygon with Attribute Values. I have created a field name called "Angle" and manually keeping some values. (Refer Screenshot)
Step 2: Go to the insert tab and click the new notebook
Step 3: Paste the script, which I have attached in mentioned in notepad and attached. (Refer Screenshot)
Step 4: make changes in two placed feature class name and attribute field name. Refer screenshot.
Step 5: Hit the Run button in a notebook
Step 6: Here is the output results
Enjoy.....
Hello,
Try using arcpy, see the code below.
def rotation(rotatefield): def rotatepoint(point, pivotpoint, angle): angle_rad = -math.radians(angle) ox, oy = pivotpoint.X, pivotpoint.Y px, py = point.X, point.Y qx = ox + math.cos(angle_rad) * (px - ox) - math.sin(angle_rad) * (py - oy) qy = oy + math.sin(angle_rad) * (px - ox) + math.cos(angle_rad) * (py - oy) return arcpy.Point(qx,qy) with arcpy.da.UpdateCursor("annotation_polygons",['SHAPE@', rotatefield]) as cursor: for row in cursor: polylist = [] for part in row[0]: partlist = [] for pnt in part: if pnt is not None: partlist.append(rotatepoint(pnt, arcpy.Point(row[0][0][0].X, row[0][0][0].Y), row[1])) polylist.append(partlist) row[0] = arcpy.Polygon(arcpy.Array(polylist)) cursor.updateRow(row)
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.