Create a custom reference grid in QGIS composer
Posted by: Gavin Fleming | in QGIS | 4 years, 10 months ago | Comments

If you need to create a reference grid like this for your map, here's a simple method.

Create one grid to show the lines with intervals in cm. The CRS setting has no effect.

Create another grid to show the labels in the centre of the visible grid cells. Again, the CRS setting has no effect. Note the offset is set to half the interval and we don't draw the lines.

Finally set up the label expression (Click the epsilon next to the custom format field)

WHEN @grid_axis = 'y'
THEN substr('ABCDEFGHIJKLMNOPQRST', (@grid_number + 2.5) / 5 , 1)
WHEN @grid_axis = 'x'
THEN (@grid_number + 2.5) / 5

Replace the 5's with your interval value and the 2.5's with your offset value.

To get full size cells across the whole map, ensure the map dimensions are multiples of the grid size (in this case 5cm):

You can still add any other graticules or effects you like; we've just stuck to the basics of setting up the regular grid and labels in this article.

This should work from 2.14; my example's in 2.18.

Acknowledgments to

PS: this has already been taken to the next level with some custom functions:

The functions referred to in the video are at

Current rating: 4.2


Have any questions? Contact us.
We would love to hear from you!
Subscribe to our Mailing list (spam-free, industry-relevant occasional emails)

Subscribe to our mailing list

* indicates required