[GIS] QGIS Print Composer – Set Map Frame to Map Extent

print-composerqgis

How do I fit the Frame (A) of the Map Item exactly to the extent of the Map Canvas (B)?

Example

I have done all of the following:

  1. In Project View, I clicked "Zoom to layer" (specifically, the widest raster layer).
  2. In Print Composer, under the Item Properties tab, specifically Extent, I clicked "Set to map extent."

These together were insufficient to move A to B.

Best Answer

Firstly, it seems like the extent of your data and your map in the composer are of different ratios - if you want your data to completely fill up the map item in the composer, you will either end up cutting out some data, or there will be some white space. So you might want to make sure your map item in the composer is more square than rectangular.

You could do this by clicking and dragging the corners of the map item using the Select/Move item tool (third down on the left).

Alternatively, you could set the extents of the map item to the extents of the largest item in your canvas (the raster background, perhaps - right click -> Properties -> Information -> Extent). You could also set the map item extents to a vector layer in your project by using a data defined override with x_min($geometryoflayer) or similar functions. I'm not sure how to do that with raster layers, I think you need custom Python code.

Otherwise I would try changing the scale of the map in the map item and moving around the content until you are satisfied, using the "Move item content" tool on the left hand side (like a map with four blue arrows on it, 4th item from the top). You can click and drag, or use the mouse wheel to increase/decrease scale. For fine tuned scale adjustments go to the Item Properties for the map and try out different scales. Note that your map item needs to be unlocked in the print composer for this to work.