I have a shapefile and I loaded it into QGIS using 'Add vector layer'. After that, I can see points in different positions.

I open the Attribute table and I can see columns "X" and "Y" with values such as (151449.965057, 204642.790761). Now I want to convert them to latitude and longitude. How can I do that?

Therefore, I use the option 'Save as' to export the data to CSV format using the CRS WGS 84.

However, nothing changes in the CSV file ("X" and "Y" stay the same as the original data).


I read and tried several suggestions from this forum without help, e.g., Converting x,y coordinates to longitude,latitude using QGIS.


2 Answers 2


Before exporting there are several more steps have to be applied.

Step 1. Create two additional fields, i.e. "lat" and "long" via the calc Field Calculator

Step 2. Apply the following expressions for "lat" and "long" respectively

For "lat" :

x(transform($geometry, 'EPSG:4326', 'EPSG:31370'))

For "long" :

y(transform($geometry, 'EPSG:4326', 'EPSG:31370'))

or alternatively, you can already use your "X" and "Y" fields with

For "lat" :

transform("X", 'EPSG:4326', 'EPSG:31370')

For "long" :

transform("Y", 'EPSG:4326', 'EPSG:31370')

Additionally, I may refer you to this article: Adding x,y coordinates to Attribute table in QGIS


This is the corresponding programming solution (Python).

import pandas as pd
from pyproj import Proj, transform

data = pd.read_csv('org_canyon_features.csv')

inProj = Proj(init='epsg:31370')
outProj = Proj(init='epsg:4326')

def f(x):
    return transform(inProj, outProj, x['X'], x['Y'])

coordinates = data.apply(lambda x: f(x), result_type='expand', axis=1)
data = pd.concat([data, coordinates], axis=1)

data.to_csv('converted_canyon_features.csv', index=None)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.