I want to rotate some polygons according to the value of azimuth from attribute table. I try to use this code but there is an error that I can not understand.
import arcpy, math fc = 'Polygons' #Change to match your data rotatefield = 'azimuth' #Clockwise rotation in degress. Change name to match your data #Function to rotate one input Point around a pivot point def rotatepoint(point, pivotpoint, angle): #Source: https://stackoverflow.com/questions/34372480/rotate-point-about-another-point-in-degrees-python 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) #Rebuild each polygon with rotated vertices with arcpy.da.UpdateCursor(fc,['SHAPE@',rotatefield]) as cursor: for row in cursor: polylist =  for part in row: partlist =  for pnt in part: if pnt is not None: #Polygons with inner rings will have None pnt(s) which can be skipped partlist.append(rotatepoint(pnt, row.centroid, row)) #Centroid is pivot point polylist.append(partlist) row = arcpy.Polygon(arcpy.Array(polylist)) cursor.updateRow(row)
_Runtime error Traceback (most recent call last): File "<string>", line 20, in <module> TypeError: 'NoneType' object is not iterable_