I created a regular grid in QGIS and want to make an atlas that moves from grid to grid. Each grid has a unique id. Under atlas configuaration I chose my grid layer as coverage layer and page name is the id. As you can see in my overview map, my map extent is to high. The right and left side of the extend is perfect. I don't know how to adjust my map extent that it represents exactly my grids. Is that possible?

enter image description here

3 Answers 3


You can't do that! Your grids are landscape (short and wide) but your paper is portrait (tall and narrow). There is no way for QGIS to make them match with out stretching your map in a way that would be very bad for your users.

Change your paper layout to landscape and you will get a better match but unless your grid exactly matches the aspect ratio of the paper (or map widget) you will always get a bit of map outside the grid square.


Of course its possible. As Ian Turton pointed out, the shape of your map item needs to match the shape of your grid cells.

How to re-size the map item to have the same aspect ratio as the grid cell

  1. Measure the height and width of a grid cell.
  2. Calculate the height-to-width ratio of the grid cell.

    height / width = height-to-width ratio
  3. Decide how wide you want your map item to be. Calculate the height of the map item by multiplying the map width by the height-to-width ratio.


If your grid cell is 1000m wide and 500m tall, its height-to-width ratio is

500m / 1000m = 0.5

If your map item is 18cm wide, the map height should be

18cm * 0.5 = 9cm

enter image description here

Note: This method works best for a map in an equal-distance projection. If distances in the map are distorted, the calculated height-to-width ratio for the grid cell will be different from the way it's displayed on the screen. In this case, calculate the height-to-width ratio from the displayed height and width. Measure the displayed width and height of the grid cell by holding a ruler up to your computer screen.


If you want to make sure you get it just right, or to use a method that can easily apply to irregular / varying grid sizes, you can use a data-defined approach in the Item Properties of your map .

Open up the Position and Size section, and click on the data-defined override next to Width, then select Edit....

In the Expression String Builder, we can call up the attributes of our atlas_geometry as follows:

bounds_height( @atlas_geometry) /
bounds_width( @atlas_geometry) *

Do the same for the Height field, but with a slight difference in the expression.

(bounds_height( @atlas_geometry) /
bounds_width( @atlas_geometry)) ^ 2 *

You may need to tweak your_value a bit to get the layout size to where you want, but as long as the same value is in each expression, your map widget will be sized exactly to the grid (or at least to its bounding box, if non-rectangular). You can also create a new global variable for your_value and have each expression reference it. Then you can update the variable once to update both.

position and size menu, edit height

atlas output 1

atlas output 2

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.