I can already create lat/lon or UTM grid in Print Composer but I was also asked about possibility to have a mix of both:
1) standard map grid using UTM – I can do this 🙂
and
2) latitude/longitude (EPSG:4326) coordinates of map item corners.
The reason is to have UTM grid to easily see the distance on printed map, but also the lat/lon coordinates for a GPS.
I would probably be able to get close to this solution with Map Corners Coordinates Plugin
https://ctu-geoforall-lab.github.io/qgis-map-coords-plugin/
and copy the coordinates from resulting text file in a text object in Print Composer.
But the plugin is still QGIS2 only and the map canvas corners might be quite different from the map item extent in Print composer.
The item properties in composer also displays some coordinates so I might be able to copy it from there but would probably need to switch to EPSG:4326 for map canvas which would distort my maps.
any idea how to do it?
PS: if there is no direct solution, does Print Composer support some sort of custom scripts or plugins we could make someone create?
Best Answer
You can retrieve the extent coordintes of map item via variables, and use them in text box.
Expression explained step by step:
To get the geometry of map item use (map item name is
map
):Retrieve the corner coordinate with
y_max
,y_min
,x_max
orx_min
For getting WGS84, use
transform
function. Example of transfrom fromEPSG:3857
:To change degrees format to DMS just use
to_dms
functionAdjust the text in box, add both corner coordinates and format as needed. Repeat the process for rest corners. Values will be automatically updated when you move the map extent.