Open AdmiralKew opened 4 years ago
You are aware that you can use the attributes of the feature to control such element as the rotation?
You are aware that you can use the attributes of the feature to control such element as the rotation?
Yes, but such a thing is finicky and time-consuming when you're working with hundreds of individual maps to generate. Sorry for the late reply.
'rotate to fit' in the 'controlled by atlas' rolldown in map properties. What this would do is rotate the map automatically to maximize the space used by the current feature.
Indeed, an automatic function for this will be great. So far I help myself with a model to prepare the data: I use the "minimum oriented bounding box" function, which generates kind of a coverage layer along with an "angle" attribute. This angle can be used to rotate the object so it best fits into your map frame. In the "Map Rotation" of your Atlas, enter
CASE
WHEN (90-"angle")> 0 THEN (90-"angle")
ELSE (180-"angle")
END
This will orient your north most of the time to the right direction and will not flip your objects upside down for landscape oriented pages.
Without this extra layer, one could maybe construct a similar rule based on this expression and other functions, which could do it on the fly:
For a start:
angle_at_vertex(shortest_line(centroid(oriented_bbox($geometry)), boundary(oriented_bbox($geometry))),0)
(found here: https://gis.stackexchange.com/a/352881)
As someone who uses the Atlas creator quite frequently, it's sometimes a bit of a pain to get everything to fit right when dealing with atlas features of varying shape and size. Sometimes one layout can work with one feature, but the next renders it invalid. I suggest:
Another feature I'd like to add is the option to quickly set margins as guides.