1

I want to create print layouts from a QGIS project, each highlighting some region of interest. For each of these regions of interest I have a polygon in a vector layer.

So my desired workflow would be:

  1. Select the polygon corresponding to a given region of interest;
  2. Create a new map layout with an extent matching the selected feature extent including page size aspect ratio.

It is important to match not just the extent but also the aspect ratio. It is not enough, for example, to select the feature, zoom to its extent, and then create a layout and click in "set to map canvas extent", because zooming to extent fits the feature to the canvas, and I want the canvas extent (or actually the page size) to be fitted to the feature extent.

2
  • Hello, does the feature have common field to join them ? can you share the name of this field for each layer to give an example that suits your needs. In the print composer you can change aspect ratio based on formula easily but it could quite hard to change other component of your print composer such as scale bar position, title position... Can you share a screenshot of what your print composer look like and which feature you want to change in your print composer. Commented Mar 8, 2022 at 9:04
  • @CorentinLemaitre Actually I discovered that the Atlas feature does sort of what I want, which is to highlight some regions defined by polygons, but the polygons themselves are not to be rendered. But still the Atlas ends up fitting the feature inside pages (or map items) of a pre-existing size. What I would like to do is that the page dimension proportions correspond of the polygon bounding box proportions, so instead of fitting geometry to page, it would fit page to geometry. Commented Mar 8, 2022 at 15:40

1 Answer 1

4

Here is a solution to change the map size in the layout based on the bounding box of the polygon. In the comment I do understand that you want the scale will be non variable and only the size of the map will vary in the layout.

Step by step

So first go to atlas, than activate it with the layer of polygon you want to study.

Then select your map in the layout and go to item properties and check controlled by atlas and then choose margin around feature. Activate atlas preview and go through atlas pages to find the right scale.

When you have decided your scale (in my example it is 1000000) you could set your map item to get a size different based on bbox of atlas element. Go to position and size of your map item then set width to be data driven.

enter image description here

The formula should be : bounds_width( @atlas_geometry ) / 1000000 *1000

Do the same for the height of your map : bounds_height( @atlas_geometry ) / 1000000 *1000

NB : I multiplicated by 1000 because the dimension of the map you give is in mm and not in map unit.

The result

I have used French department data, to get map of Loire-atlantique (first) and Paris (second).

enter image description here

Paris with the same scale

enter image description here

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.