Labeling grid automatically using QGIS

To get that result in QGIS 3.14:

  • Check the 'Geometry generator' option inside the labels options and add make_point(x_min( $geometry), y_max( $geometry)) in the expression box
  • Select 'Offset from point' placement
  • Select the bottom right Placement Quadrant
  • Adjust the 'Offset X,Y' settings to move the label a little away from the corner if necessary

enter image description here

An alternative method for older QGIS versions:

  • Duplicate your layer (we'll use one layer for the grid and another for the labels)
  • Select 'Single Symbol' styling
  • Select 'Geometry Generator' as 'Symbol layer type'
  • Select 'Point/Multipoint' as 'Geometry type'
  • Add make_point(x_min( $geometry), y_max( $geometry)) in the expression box
  • Change the 'Symbol layer type' under 'Geometry Generator' from 'Simple marker' to 'Font marker'.
  • Set the 'Anchor point' to 'top left'
  • Click on the 'Data defined overide' button next to the 'Character' box and select 'Edit'.
  • In the window that pops up type in the field name (between double quotes) you want to use to label.
  • Click OK
  • Adjust the 'Offset X,Y' settings to move the label a little away from the corner if necessary

enter image description here

enter image description here

enter image description here

enter image description here


To completely answer the question we need to extend the answer of Michel by adding a label to any grid squares cut off by the top and left hand edges of the canvas. This can be done by updating the geometry expression to:

make_point(x_min(intersection(@map_extent, $geometry)), y_max( intersection(@map_extent, $geometry)))

enter image description here

Tags:

Labeling

Qgis