# Automatic rotation of maps in composer to maximize scale of object of interest

We are working on a composer atlas of hundreds of maps showing highway routes, all of which are north-oriented. We would like to be able to rotate these maps to the ideal rotation that maximizes the scale that the route can be displayed. I believe the best way to calculate this would be by looking at the dimensions of the minimum bounding box of the route, compared to the dimensions of the map frame.

For example, suppose that I have a route whose MBB is 300m in the X dimension and 100m in the Y dimension (3:1 ratio). In comparison, the ratio of the map frame is 2:3 (taller than wider). Is there a way to calculate the angle that the map needs to be rotated away from north so that the MBB of the route at this rotation becomes 2:3, which should maximize the scale that it can be displayed?

• this is related to gis.stackexchange.com/questions/250530/… Aug 25, 2017 at 14:43
• Related, but different. Now knowing that a value can be included in a field to rotate the map automatically, I believe it's become more of a math problem about how to calculate this rotation. Aug 25, 2017 at 17:38