QGIS – How to Export Coordinates of Polylines in Latitude/Longitude Scheme

coordinatesexportlatitude longitudeqgis

I want to export line coordinates of several features of a layer into a CSV file.

This is easily possible with Export -> Save Selected Features As... and choosing Geometry: AS_WKT:

enter image description here


However, this approach will write the coordinates in the scheme of Longitude Latitude into the CSV file (e.g. 11.3307, 50.9829), like seen below:

enter image description here

OpenStreetMap uses coordinates the other way around in scheme of Lat/Long (e.g. 50.9829, 11.3307) – this is what I need.

How can I export coordinates into the CSV in the way of Latitude Longitude?

Best Answer

First, let's emphasis that it is a strange requirement... CRS and axis order are tightly coupled, so the clean solution is to export and load the data using the same CRS.

That being said, you can create the (not anymore)Well-known-text using swapped coordinates using a virtual layer.

Go the the menu layer / add layer / add-edit virtual layer and enter the following query.

select *, st_astext(SwapCoordinates(geometry)) as lat_long_text 
from myLayer

You can then export this new dynamic layer as CSV, omitting the geometry field.

enter image description here