Auto-Generate a Print-Ready A4 Map Layout in QGIS

QGIStutorialmap layoutcartographyPython

Setting up a QGIS print layout manually — adding a map frame, scale bar, north arrow, legend, and title — takes several minutes even for experienced users. This script does the whole thing in one run and opens the Layout Designer so you can tweak before exporting.

What it does

The create_map_layout.py script creates an A4 map layout from whatever is visible in the current QGIS canvas view. It automatically adds:

  • Map frame — the current canvas extent
  • Scale bar — metres, positioned at the bottom of the page
  • North arrow — top-right corner
  • Date title — today’s date as the map title
  • Legend — all visible vector layers with their current symbology

Once generated, the layout opens in the QGIS Layout Designer where you can make final adjustments before exporting to PDF or image.

What you need

  • QGIS 3.28 or newer
  • Layers loaded and styled in QGIS — the script captures the current canvas view
  • The create_map_layout.py script from the GIS Utilities Pack

Steps

  1. Open QGIS and style your layers the way you want them to appear on the map.
  2. Pan and zoom the canvas to the extent you want to print.
  3. Open Plugins → Python Console → Show Editor.
  4. Paste the script. Find the ORIENTATION variable near the top and set it to 'portrait' or 'landscape' (default: 'landscape').
  5. Click Run. The layout opens in the Layout Designer.
  6. Make any final adjustments and export via Layout → Export as PDF.

Tips

  • Legend entries — only checked (visible) vector layers appear in the legend. Hide layers you don’t want included before running.
  • Title — the script uses today’s date as the title. Rename it in Layout Designer if you need a custom title.
  • Scale bar units — set to metres. For large-scale maps covering hundreds of kilometres, change the unit in the scale bar properties.

Get the script

create_map_layout.py is part of the GIS Utilities Pack — four everyday QGIS automation scripts for $25 USD.