I am trying to export polygon coordinates from a shapefile to a CSV file, but so far all my attempts have failed. I have found numerous questions and answers about this, but none have solved my problem.

I have downloaded the file

www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries.zip

which is a shapefile containing a basic world map. I have imported the shapefile into QGIS by adding a vector layer, and then I try to export the polygons with coordinates for each country. The tips that I have found suggest either saving the layer by right-clicking it and then selecting Save as or opening the attribute table and copying it into Excel. If I try these I only get master information with one row for each country in the map.

Does anyone know how I can retrieve detail information for each country containing the polygons with coordinates?

  • 1
    So you want coordinates for all vertices ("corners") for all polygons exported? That could be quite a lot of rows. What you probably get now is the centroid. Can I ask what you need this for - maybe there's an easier way to accomplish what you want to do? – Martin Aug 6 '14 at 7:56
  • Would Well know Text(WKT) representation be enough for you? – vinayan Aug 6 '14 at 7:59
  • I am not familiar with WKT, but from what I have found on the web it seems that it will be a bit difficult for me to use. I need the data in a csv file. The shape file I am using here is only for testing, I will not use it in my work. I am working with some special geograpghical zones related to fisheries. These zones are stored in a database. I would like to import the shape file data into the database for comparison purposes. I was hoping that I could find a way of exporting the coordinates for one chosen country in my test file to a csv file and then import it into the data base. – Sveinung Aug 6 '14 at 11:05
up vote 11 down vote accepted

Use the plugin MMQGIS to export geometry to csv. I just try with your file, it works perfectly.

enter image description here

  • Great! I think this may solve my problem! Here I am able to connect attributes and nodes. The real files that I will be working with will be much smaller than my very large test file. I think this is just what I was looking for. Thanks a lot! Unfortunately my reputation is still too low to vote anything useful. – Sveinung Aug 6 '14 at 11:38

Choose Layer > Save As... with format as CSV. Make sure 'Layer Option', 'GEOMETRY' is set to AS_WKT in the 'Save vector layer as...' window. The first column of the CSV file will now include polygon coordinates.

  • That worked! I got the coordinates! However, it will be a bit awkward using them as I need the data in a CSV file. I don't know if there is any easy way of converting from this format to csv. But this was very useful. Thanks! – Sveinung Aug 6 '14 at 11:15

You can use this simple app to load a shapefile, and then export as X/Y's

http://www.qarah.com/shapeviewer/#download

  • That worked too! But here it seems I will have some problems connecting the coordinates to a country. If I export the attribute table with the country names I can find no obvious relation between the two data sets. I need both the master and detail information. But this is a neat little app that I will continue using. Thanks! – Sveinung Aug 6 '14 at 11:21

A Greek way: A) Select the feature you want, copy it and paste onto a word processor. B) delete the first part wkt_geom… and the parenthesis at the end so there are only numbers. C) Replace: ,(comma and one space) with ^p (MS word) or \n (Libre office-Open office) D) replace one space with comma. You get the list of coordinates in the X,Y format.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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