Created a global map by adding the OpenStreetMap and WorldMap layers in QGIS. Drew polygons over that, creating what I believe is a polygon layer.

I've also created a layer of the Nodes/Vertices of the Polygon by clicking Vector > Geometry Tools > Extract Vertices (see photo).

Would like to extract the latitude and longitude of these polygon points (CSV, GeoJSON, or somehow connect to MSQLServer eventually).

I've tried adding calculated fields to the Attribute Tables of the Vertices layer following but am new to GIS and have been unsuccessful.

Example of the Polygons I'm trying to get the latitude/longitude of

3 Answers 3


Open your attribute table of the layer you want to add this information to and its field calculator. Create a new field with data type double/real and give it a length and precision of your choice. Name it x/lng and y/lat and insert the expression

x(transform($geometry, layer_property(@layer_name, 'crs'), 'EPSG:4326'))

for longitude and

y(transform($geometry, layer_property(@layer_name, 'crs'), 'EPSG:4326'))

for latitude.

This expression will work with every source crs, so you do not need to care about that. In case your layers crs already is EPSG:4326, it would be enough to just enter the expression $x or $y.

  • Hi, is there a way to directly add the latitude and longitude of the vertices in the polygon layer itself ? I have a polyline and want to the do the same. I want the lat lon of the head and the tail node of each line in the polyline layer. May 6, 2020 at 0:47
  • With a precision of 8, shouldn't the length be 11? The tooltip for Output field length says "Total length of the field (including the number of digits after the decimal place for decimal fields). For example, 123.45 requires a decimal field length of 5". Nov 2, 2021 at 15:53
  • @mrXsquared I want to do the same but I would like to get only one coordinate for my polygon with a format that looks like something similar to 54° 5' 0.0096'' N and 12° 6' 31.7196'' E. Do you know how to do?
    – Robagb
    Mar 22 at 19:17

If you need latitude and longitude as csv you may simply right click your vertices layer and choose Export > Save Features as...:

enter image description here

Then in the dialogue chose Comma Separated Value [CSV] in the combo box on top:

enter image description here

Chose a file name and if applies various restrictions for the output (attributes to export, extent,...). Scroll down and under Layer Options select the output format for your coordinates (here I chose 'AS_XY'). Note the tooltip!

enter image description here

The result will be something like (opened in Notepad++):

enter image description here


Another approach utilizes the QGIS's native geoalgorithms.

Let's assume there is a polygon layer called 'test', see the image below.


Step 1. Use the "Extract vertices"


Step 2. Apply the "Add X/Y fields to layer". On this stage set up the Coordinate System appropriately


Step 3. (Optional) Do whatever you want :)
e.g. export the result of the Step 2 as a CSV file via RMC > Export > Save Feature As...

  • 1
    I like especially step 3 .... :-))))
    – Babel
    Nov 2, 2021 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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