# Rotating fishnet made of minimum bounding boxes?

Given a grid of points, I had to create something similar to a fishnet, and did so using the buffer -> minimum bounding geometry option as listed here (option A).

Since my grid comes from Climate Models, it is rotated (alpha=15.16 degrees counterclockwise). The fishnet obtained has no such rotation, however, and I need to rotate it by the same alpha angle.

My fishnet has `170090` individual objects (466 columns and 365 rows), and this is because each square had to inherit an `order` field from the point it contains, so I have not dissolved the squares into a unique object.

How can I rotate all my squares by alpha?

Each square has to rotate relative to its center.

• Please include the steps that you used to create your fishnet within your question. Potential answerers may or, in my case, may not be willing to follow a link to try and synthesize your question. Doesn't your question distil to "How do I rotate a square polygon by alpha using ArcPy?" Once you can do it for one automating it to cursor through your feature class to do the remainder should be straightforward. – PolyGeo Feb 3 '17 at 9:23
• Please don't use the term "fishnet" to refer to a sparse pattern of polygons. A fishnet could be created to contain your systematic sampling pattern, but it is not a fishnet in of itself. – Vince Feb 3 '17 at 12:13
• @Vince this only looks like a sparse pattern of polygons. There was no point in showing all `170k +` of them. I get it it might not be an ortodox fishnet, but this is what it is at the core of my population of squares, where the latter reproduce the Moore neighborhood. – FaCoffee Feb 3 '17 at 13:11
• Fishnets are mutually exclusive, exhaustively complete partitions of space. What you have is a rotated, regularly distributed, systematic sampling scheme. You actually showed too many features, since the graphic wasn't legible on a 5-inch screen. – Vince Feb 3 '17 at 14:07

## 1 Answer

Script below will create a new polygon feature class with features rotated counterclockwise around centroid.

``````import arcpy,math
arcpy.env.overwriteOutput=1
original_fc=r'C:\TEST.gdb\unrotatedPolygons'
copied_fc=r'C:\TEST.gdb\rotatedPolygons'
arcpy.CopyFeatures_management(in_features=original_fc, out_feature_class=copied_fc)
rotation=15.16 #counterclockwise rotation in degrees
with arcpy.da.UpdateCursor(copied_fc,'SHAPE@') as cursor:
for row in cursor:
array1=row.getPart()
centroid=(row.centroid.X,row.centroid.Y)
for vertice in range(row.pointCount):
pnt=array1.getObject(0).getObject(vertice)
pnt.X=math.cos(math.radians(rotation))*(pnt.X-centroid)-math.sin(math.radians(rotation))*(pnt.Y-centroid)+centroid
pnt.Y=math.sin(math.radians(rotation))*(pnt.X-centroid)+math.cos(math.radians(rotation))*(pnt.Y-centroid)+centroid
row=arcpy.Polygon(array1)
cursor.updateRow(row)
`````` Math explained: How can I rotate a coordinate around a circle?

• What happens when you have a true fishnet, with rectangles partitioning the datat extent? Rotating the shapes about their centroids won't address the same problem as rotating with respect to a common origin. – Vince Feb 3 '17 at 11:33
• It will become a weird fishnet. But from what i can see in his screenshot the script will work. – BERA Feb 3 '17 at 11:47
• I guess I got hung up on the term "fishnet" which does not apply to the OP's data set. – Vince Feb 3 '17 at 12:03