In QGIS, I have a polygon layer with square polygons in it. The polyogons are of same size but different orientation. I want to create a set of maps using the atlas feature. My aim is to rotate the map accordingly to the orientation of the polyogns.
The "item properties" offer the possibility to insert an expression for the map rotation. If I had a rotation-field in the property table of the poygons layer I'd be able to automate map rotation accordingly, I suppose. So my question is: is it possible to calculate the rotation of quadratic polyon features relative to the N-S (or W-E) axis?
Here I found a similar question; however, not being familiar with PostGIS, I want to accomplish this in QGIS.
(180/pi())* atan2($y_at(1)-$y_at(0), $x_at(1)-$x_at(0))
should get you an angle for the first two points.180/pi() * azimuth(make_point($x_at(0), $y_at(0)), make_point($x_at(1),$y_at(1)))
(which is probably just 90 degrees away from the previous example)