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.
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'))
ST_X(ST_Transform(geom,32735,4326))
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 …