Is it possible to rotate each individual atlas detail map separately?

In creating an atlas for a long linear feature (rivers) to be output in engineering-style pages (11 x 17), it is nice to include as much and as consistent of an amount of the linear feature in each separate detail map as possible. Having the map oriented to N is not a particular priority. I understand how to rotate my whole canvas in the main app, and how to rotate a map rectangle within composer, but neither of these addresses the goal exactly.

My use case example is below. Each yellow polygon covers a 15 miles section of river. I want to rotate each atlas panel to 'flat' according to the bottom of the polygon, so that in each panel the visible river feature extent will be as-wide horizontally as possible.


1 Answer 1


I believe I achieved what you want by doing these steps:

  1. Create a line shapefile with two attributes id and length
  2. Split this file by a maximum length based on the length of the line (in my case 5000 m resulting in 6 segments). I update the id (= row_number) and length (length($geometry)): Split
  3. Perform a Oriented minimum bounding box on the Split layer: Bounding boxes
  4. Delete all the attributes but id and length in Bounding boxes layer
  5. Perform a Force right-hand-rule on Bounding boxes: Reoriented
  6. Perform a Oriented minimum bounding box on the Reoriented layer: Bounding boxes (remove the first layer called Bounding boxes and Reoriented to keep track of the layers in use)
  7. Calculate a new attribute in the Bounding boxes layer called "rotation" based on the angle, width and height of the bounding boxes:

    case when width < height then 90-angle when angle = 0 then 0 else 180-angle end

Layers and table

Create a new print layout. Add a map (Map 1) showing the line-layer. Use Bounding boxes as Coverage layer in the Atlas, and let Map 1 be controlled by the Atlas. Use no Background (uncheck). Add this Expression (data defined override) for the Rotation:

attribute(@atlas_feature, 'rotation')

The Map 1 frame will now rotate while the current atlas feature always will be horizontal.

In addition I added this expression for the map scale to ensure no scale larger than 1:45000:

case when @map_scale < 45000 then 45000 else @map_scale end

Items Map 1


NB! Remember to save the temporary layers! Otherwise they will be deleted when closing QGIS.

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.