7

When I try to print under QGIS, due to the framing, it prints me 4 pages. Looking more closely, and one by changing the angle of the 2 pages, I am at 2.

How do I automate this?

Current situation: current situation

Hoped-for situation: hoped-for situation

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
  • It6 a big one https://gis.stackexchange.com/questions/154975/minimising-number-of-dynamic-pages-to-map-scattered-points-using-arcgis-desktop – FelixIP Jan 12 '21 at 22:03

1 Answers1

2

You can use the Atlas function in QGIS and select the layer with your features (the blue lines in your example) as coverage layer. Than QGIS prints a separate page for each feature and fits all the features to the page (with the option to define an additional margin).

If you want to create something like a grid, but only get a cell for each feature and one that is oriented in the right direction, use Menu Processing / Toolbox / Minimum bounding geometry, see the output: yellow polygon layer, let's call it cover. This layer will be used in the atlas instead of the grid, where you would need not less than 9 pages.

enter image description here

You can now use this layer cover as cover layer for your atlas, so no empty pages will be created and the features will all fit exactly on the page. To rotate the page, set map roatation to data driven override in the element properties and paste an expression like: 90 - main_angle ($geometry):

enter image description here

And this is the oupupt of the atlas: two pages with features fitting (+1% margin). The north arrow shows you the rotation:

page 1: enter image description here

page 2: enter image description here

page 3: enter image description here

Babel
  • 71,072
  • 14
  • 78
  • 208
  • I know and I know how to do it in QGIS, the concern is that I have thousands of plans of different natures, my goal is to extract the plans from each SHP, and to chew the ground in QGIS, moreover QGIS uses a grid and only searches for empty boxes, without being able to optimize them cordially – patrickblancseau Jan 23 '21 at 07:49
  • I don't understand your problem: you have "plans" - what do you mean with that? Layers? Features? You only want some of the features be shown on a separate page? And what "grid" are you speaking about? And atlas function only searches for "empty boxes"? Sorry, I'm completely confused. Please explain your settings and problem more detailed, ideally add a screenshot to be able to understand the problem. – Babel Jan 23 '21 at 09:27
  • You mean you have a grid layer you use as coverage layer for the atlas? You should use the layer containing the shapes you want to show on the atlas page as coverage layer. Than QGIS automatically sets the extent of the page to the extent of the shape. – Babel Jan 23 '21 at 09:39
  • Hello, indeed you are right, the concern is that QGIS does not create a grid made up of 4 polygons, to have the extent of the map. In my case, I try to have an algorithm which creates 4 polygons (ex: A4 or A1), totally separated but which would orient itself according to the example map -> the 1 ° and top right at 45 ° -> the 2 ° in the middle at 90% and the 3 ° -> the 3rd at 75% at the bottom left to take the last part of the map The goal is when printing to win a page – patrickblancseau Feb 05 '21 at 15:12
  • Can you create a grid and then shift it (using affine transformation) and delete those grid-cells that are empty? See here for something similar: https://gis.stackexchange.com/a/382480/88814 – Babel Feb 05 '21 at 15:23
  • Hello I do not know the affine transformation, I will look precisely. But how can I go from my 1st drawing (6 polygon) when 2 is enough (2nd drawing, or more or less – patrickblancseau Feb 05 '21 at 16:22
  • Updated my solution, I think now it's closer to what you asked for. – Babel Feb 05 '21 at 16:34
  • hello thank you for your answer that allowed me to discover the python function .minimum_rotated_rectangle and move forward on my project, the concern that I encounter and that on qgid, if one of the polygons needs 2 pages to print at the right scale, this blocked – patrickblancseau Feb 08 '21 at 21:19