Table of Contents
UTM Grid Labels in QGIS
Here are some expressions for creating different sorts of UTM grid labels in QGIS.
Basic 2 digit
4 digit
lpad(substr(@grid_number,1,-3),4,'0')
If you want the prefix in a smaller font, you can use some HTML:
'<span style=“font-size:6pt; ”>'||lpad(substr(@grid_number,1,-5),2,'0')||'</span>'||'<span style=“font-size:10pt; ”>'||substr(@grid_number,-5,2)||'</span>'
I previously used modular arithmetic to get the different parts of the grid number, but the substr approach above is simpler eg:
'<span style=“font-size:6pt; ”>'||lpad((@grid_number - @grid_number % 100000) / 100000, 2,'0')||'</span>'||'<span style=“font-size:10pt; ”>'||lpad((@grid_number % 100000 - @grid_number % 1000) / 1000, 2,'0')||'</span>'
Full 6/7 digit
Probably doesn't make much sense unless you are using different sized fonts:
'<span style=“font-size:6pt; ”>'||substr(@grid_number,1,-5)||'</span>'||'<span style=“font-size:10pt; ”>'||substr(@grid_number,-5,2)||'</span>'||'<span style=“font-size:6pt; ”>'||substr(@grid_number,-3,3)||'</span>'
If you want E/N on the end (for easting/northing), then you can add it:
'<span style=“font-size:6pt; ”>'||substr(@grid_number,1,-5)||'</span>'||'<span style=“font-size:10pt; ”>'||substr(@grid_number,-5,2)||'</span>'||'<span style=“font-size:6pt; ”>'||substr(@grid_number,-3,3)||'</span>'||if(@grid_axis='x','E','N')





