QGIS – Atlas Map Rotation Techniques

atlasqgis

I work on trails and frequently need a series of maps that follow the trail. I've been able to create an Atlas, but I'm struggling to get each map to rotate with the trail.

Here's my current process:

  1. Create a layer where I define the segments that I want (in this case, I called it AtlasMapViewLines)
  2. Draw line segments for each view that I want (I've read about the options for automating this, but in our case I actually want to control what each map covers, so I'm fine drawing each segment)
  3. Create a new attribute (in this case called Main_Angle) with the field calculator to calculate the angle of each line using the following forumla: main_angle($geometry)
  4. Create a new layout & generate an Atlas using the AtlasMapViewLines layer that I created.

So far, so good — this generates an Atlas of each segment that I've defined. At this point, all the maps are north up and scaled to fit. The problem comes when I try to get them to rotate. Here's my next step:

  1. In Item Properties, Map rotation, I click on Data Defined Override > Field Type … > and select the Main_Angle attribute.

The maps all rotate, but not in a way that I want. Firstly, the segment is not horizontal, as I'd like. Secondly, north is now down!

Here's a screenshot — the purple lines are the segment lines that I'm using to define the Atlas. The orange and blue arrows are just visual markers for me to see the end of the lines.

[screenshot of map with a purple line running diagonally from the upper left to lower right corner. A large north arrow is pointing to the lower left. ]1

Best Answer

To get the line segment horizontal, use 90-"Main_Angle"

enter image description here