I am customising a layout map to print it in PDF with QGIS. I have a Box where i would like to automatically display the coordinates of the center of the map if possible.

How can I do it?

enter image description here

I am guessing I have to edit the following.

enter image description here

2 Answers 2


Get them with:

map_get(item_variables('Map 1'),'map_extent_center')

which returns a <geometry: Point>. Then extract x and y values as you like, for example:

'X-Centroid: ' ||
x(centroid(map_get(item_variables('Map 1'),'map_extent')))
|| ' - ' ||
'Y-Centroid: ' ||
y(centroid(map_get(item_variables('Map 1'),'map_extent')))

Replace Map 1 with the name of your map in print layout.

  • 2
    Correct. You might need to add a to_dms to help about coordinates formatting maybe.
    – etrimaille
    Sep 20, 2021 at 19:53
  • Could you please explain me how to get this approach? I am trying like: to_dms (x(centroid(map_get(item_variables('Map 1'),'map_extent')))) But it doesnt work. Thanks.
    – Serggg182
    Sep 21, 2021 at 10:24

To get the result in DMS, try this expression construction:

'B: ' ||
to_dms(y(transform(centroid(map_get(item_variables('Map 1'),'map_extent')), map_get(item_variables('Map 1'),'map_crs'), 'EPSG:4326')), 'y' , 2, 'aligned')
|| '\n' ||
'L: ' ||
to_dms(x(transform(centroid(map_get(item_variables('Map 1'),'map_extent')), map_get(item_variables('Map 1'),'map_crs'), 'EPSG:4326')), 'x' , 2, 'aligned')
  • Thanks a lot, it works perfectly and it is exactly what i wanted :)
    – Serggg182
    Sep 24, 2021 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.