# Rotate features in ArcGIS 10

I have a series of polygons that I want to rotate. Each polygon has a rotate angle field and an anchor point xy coordinate fields. All anchor point xy's are on a node of the polygon. What is the best way to do this using arcgis/arcpy? I know we can rotate them when in editing mode, but I don't want to do them all manually since they are all different. I would prefer a Python answer so I can automate it and build it into my work flow.

Thanks

-
 This is not something that I have done but you seem to be facing a similar issue to that discussed at gis.stackexchange.com/questions/13383/… – PolyGeo Apr 5 '12 at 1:22 You can do this with ArcObjects. Would programmatic solution be acceptable? – Jakub Apr 5 '12 at 14:13 Are your features in geographic or projected coordinates? – blah238 Apr 5 '12 at 21:43

## 2 Answers

Assuming you are using a projected coordinate system... (gets way more complicated if you are not)

Given point of rotation (X,Y) and rotation angle t, you need to rotate each point in the polygon in sequence. Assuming the polygon is built of points in set such that set = [(x0,y0), (x1,y1), (x2,y2)...]

You need to rotate each point in the set, in sequence, to form set' = [(x0',y0'), (x1',y1'), (x2',y2')...]

To rotate, first you have to transform the coordinate system to origin. (x,y) is the point to be rotated.

``````x_trans = x - X
y_trans = y - X
x_transprime = Cos(t) * x_trans - Sin(t) * y_trans
y_transprime = Sin(t) * x_trans - Cos(t) * y_trans
x_prime = x_transprime + X
y_prime = y_transprime + Y
``````

This should be pretty straightforward to translate into a python script.

-
 Thanks for adding the python section Mike Toews – blord-castillo May 13 '12 at 14:04

Here is a discussion from the ESRI Forums that may be a solution for you. Look for the ESRI response. It involves converting the polygons to rasters, using the Rotate raster tool, and converting back to polygons. However, there may be some concern about the polygon boundaries getting messed up as you convert back and forth between raster/vector.

The good news is that it can all be done in Python without calling ArcObjects. And you should be able to use SearchCursor to grab your rotation angles and anchor points from the attribute table.

Anyway, just a possible alternative.

-