1

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.

Image: enter image description here

4
  • 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
    Commented Feb 3, 2017 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
    Commented Feb 3, 2017 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
    Commented Feb 3, 2017 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
    Commented Feb 3, 2017 at 14:07

1 Answer 1

3

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[0].getPart()
        centroid=(row[0].centroid.X,row[0].centroid.Y)
        for vertice in range(row[0].pointCount):
            pnt=array1.getObject(0).getObject(vertice)
            pnt.X=math.cos(math.radians(rotation))*(pnt.X-centroid[0])-math.sin(math.radians(rotation))*(pnt.Y-centroid[1])+centroid[0]
            pnt.Y=math.sin(math.radians(rotation))*(pnt.X-centroid[0])+math.cos(math.radians(rotation))*(pnt.Y-centroid[1])+centroid[1]
        row[0]=arcpy.Polygon(array1)
        cursor.updateRow(row)

enter image description here

Math explained: How can I rotate a coordinate around a circle?

3
  • 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
    Commented Feb 3, 2017 at 11:33
  • It will become a weird fishnet. But from what i can see in his screenshot the script will work.
    – Bera
    Commented Feb 3, 2017 at 11:47
  • 1
    I guess I got hung up on the term "fishnet" which does not apply to the OP's data set.
    – Vince
    Commented Feb 3, 2017 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.