QGIS Script · Python
A4 Map Layout Generator
Auto-generates an A4 map layout — portrait or landscape — from the current QGIS canvas view. Adds a scale bar, north arrow, date title, and legend at default positions. Opens in the Layout Designer so you can resize and reposition elements before exporting to PDF.
What you get
create_map_layout.pyWhat it does
Portrait or landscape
Set ORIENTATION to "portrait" or "landscape" at the top of the script before running. Default is landscape. The page size is set to A4 in the chosen orientation.
Scale bar, north arrow, title and legend
Adds all four map elements automatically — placed at sensible default positions on the page. Resize and reposition them in the Layout Designer to suit your map.
Legend from visible layers
Builds a legend from all currently visible vector layers and their symbology. Hide layers you do not want included before running the script.
Opens in Layout Designer
The layout opens in the QGIS Layout Designer immediately after running — adjust element sizes and positions, rename the title, then export to PDF.
How to use it
- 1
Style your layers and pan/zoom the QGIS canvas to the extent you want to print.
- 2
Hide any layers you do not want in the legend.
- 3
Open Plugins → Python Console → Show Editor.
- 4
Paste the script. Set
ORIENTATIONnear the top to"portrait"or"landscape". - 5
Click Run. The layout opens in the Layout Designer.
- 6
Resize and reposition the scale bar, north arrow, legend, and title as needed.
- 7
Export via Layout → Export as PDF.
Requirements
- QGIS 3.28 or newer
- No additional packages needed — uses QGIS layout APIs
- Layers styled and visible in the canvas as desired
Also in the GIS Utilities Pack
Get all 4 GIS utility scripts for $49 — save $29 vs buying individually.