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.

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 )

Google photo

You are commenting using your Google 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.