Latitude and Longitude of projected points in QGIS

Often one has points in QGIS in a given coordinate system and wants them in latitude and longitude for various reasons. Solutions I have used in the past included converting to WGS84 EPSG:4326 and then using the field calculator in QGIS to calculate X and Y values for Longitude and Latitude respective, exporting to CSV while projecting to 4326, or pulling into PostGIS and writing a function.

I got tired of those shenanigans for our field survey around Gishwati National Park in Rwanda this week, and finally wrote something in QGIS functions.

gishwati_sample.png

For X, we use the field calculator with either x_min or x_max (doesn’t matter for points) applied to the transform of the geometry from UTM Zone 35 S or EPSG:32735 (in our case) to geographic in WGS84 or EPSG:4326:

x_min(transform($geometry,'EPSG:32735','EPSG:4326'))

This feels a lot like the equivalent PostGIS which is very satisfying:
ST_X(ST_Transform(geom,32735,4326))
There are interesting alternatives to this approach in QGIS and prior art here.

One thought on “Latitude and Longitude of projected points in QGIS

  1. I’ve tried x_max(transform( $geometry,4326,32647))
    but giving wrong result: x max is still in WGS 84 …

    thanks for correcting me that it needs an input of string …
    changing it into string ‘EPSG:4326’ as your noted, solve my problems

    Thanks …

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.