QGIS – How to Extract Latitude & Longitude from Polygon Shapefile Using QGIS

coordinatesextractpolygonqgis

Could you help me to create long & lat (x and y coordinates in degrees) for polygon shapefile?

When I used directly QGIS export vectors to csv file, it didn't work.

Here is the example file: https://drive.google.com/drive/folders/1lfkwMQADzsiMKCZsOeuFqQAHGUE9Qni8?usp=sharing

Best Answer

In the case you have polygon shapefile, you need to first extract lat and long coordinates for the polygons. This is typically done as coordinates of centroids. But you can also extract minimum, maximum etc.

Your shapefile also must be in some coordinate system which uses degrees (lat, long) - if it is not, you need to first reproject it (Vector / Data management tools / Reproject Layer...).

  1. Select layer in layer list and Open Field Calculator (abacus icon in top menu). Or Right click on layer / Open attribute Table to see all columns and click on abacus icon in top menu of table window.

  2. Select if you want to create new field or update existing (if you use existing field make sure the field type is number type with enough decimals)

  3. As expression write for long: x(centroid($geometry)), for lat y(centroid($geometry))

Once you have both lat and long fields filled in you can export the layer (or better say attribute table) into csv.

Related Question