Is it possible to put the projection of a map of a layout in a text label in a layout in QGIS?
Yes it exists in QGIS 3.2. In fact, this function was added in QGIS 3.0: check Expressions in QGIS 3.0 changelog. You need to insert a text box and there you can add expression:
@project_crs
and the projection will be added on the map. If you need more details, you can add this expression to the above one:
@project_crs_definition
Which will give you the CSR and its definition:
IN QGIS 2.18. you can solve the problem if you are familiar with a bit of python. The function used in this can be found here in the docomentation.
- When creating a new label go to "insert an expression"
- Change to the "function editor tab and click new file
- insert the code below and hit "Load"
- go back to "expression" and insert
show_crs(" ")
- Resulöt will be as seen in the image.
You can fine-tune the strings if needed.
from qgis.core import *
from qgis.gui import *
from qgis.utils import *
@qgsfunction(args='auto', group='Custom')
def show_crs(val, feature, parent):
canvas = iface.mapCanvas()
epsg = canvas.mapRenderer().destinationCrs().postgisSrid() # yields the EPSG Code
#short = canvas.mapRenderer().destinationCrs().projectionAcronym() # yields the short version
prj_string = canvas.mapRenderer().destinationCrs().toProj4() # yields a
#map = canvas.mapRenderer().destinationCrs().toWkt() # yields a WKT string
crs_string = "%s %s" %(prj_string.split("+")[1], prj_string.split("+")[2])
map = "EPSG: %s \n Projektion: %s" % (epsg, crs_string)
return map