QGIS MGRS Notes

Abstract

QGIS is a free geoinformation system. This document collects my usage notes for QGIS focusing on usage together with MGRS (Military Grid Reference System).

Useful Plugins

EPSG Codes to Use

Description EPSG Recommendation
WGS84 UTM 32n 32632 Use this by default
ETRS89 UTM 32n 25832 Possible source format; compatible for small scales
ED50 UTM 32n 23032 Do not use except for legacy applications
Gauß-Krüger Zone 2 31466 Do not use except for special applications
WGS84 world-wide 4326 Might sometimes make sense to use
Google Maps 3857 Use as “convert from” EPSG

Configuring an MGRS Grid

The following code can be used to create labels that indicate UTM coordinates (if one leaves out the brackets while reading) and MGRS coordinates (if one ignores the brackets while reading). This comes close to the typical notation of having the UTM parts in superscript numbers (which for sure can be configured somehow, too). Use a custom formatter expression for both axes:

case
when @grid_axis = 'x'
then
    CONCAT('[', floor(@grid_number/100000), ']',
        case
        when (@grid_number/1000 - floor(@grid_number/100000)*100) < 10 then '0'
        else ''
        end,
        @grid_number/1000 - floor(@grid_number/100000)*100)
when @grid_axis = 'y'
then
    CONCAT('[', floor(@grid_number/100000), ']',
        case
        when (@grid_number/1000 - floor(@grid_number/100000)*100) < 10 then '0'
        else ''
        end,
        @grid_number/1000 - floor(@grid_number/100000)*100)
end

Add Label Coordinates in MGRS

'32UMB' + to_string(floor(x(transform(make_point($x, $y), 'EPSG:4326', 'EPSG:25832')) - 400000)) + lpad(to_string(floor(y(transform(make_point($x, $y), 'EPSG:4326', 'EPSG:25832')) - 5600000)), 6, '0')

Tricks

Useful non-QGIS Resources

Coordinate Conversion

GeoConvert from package geographiclib-tools can be used to convert Google Maps LatLon to MGRS:

> echo 52.51627404556164, 13.377684321544193 | GeoConvert -m
33UUU8991619699

Also available online https://geographiclib.sourceforge.io/cgi-bin/GeoConvert or by shortlink https://is.gd/utmmgrs.

Note that Google Search results (which do not point to hostname maps.google.com) seem to lack the context menu for copying the coordinate?

GeoTIFF Merging

https://gis.stackexchange.com/questions/2195

GDAL_CACHEMAX=1024 gdal_merge.py -of GTiff -co COMPRESS=LZW -co BIGTIFF=YES -o all.tiff in1.tif in2.tif ...

Ma_Sys.ma Website 5 (1.0.2) – no Flash, no JavaScript, no Webfont, no Copy Protection, no Mobile First. No bullshit. No GUI needed. Works with any browser.

Created: 2022/05/21 20:53:06 | Revised: 2024/08/22 19:56:47 | Tags: kb, qgis, mgrs, epsg | Version: 1.0.0 | SRC (Pandoc MD) | GPL

Copyright (c) 2022 Ma_Sys.ma. For further info send an e-mail to Ma_Sys.ma@web.de.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.