Export Polygons to CSV – How to Export Polygons with Coordinates

csvqgis

I am very new to QGIS, so please bear with me.

I have a ".shp" file, which is contains a set of boundaries for suburbs of Australia. I opened it to QGIS and I would like to export it into a CSV file so that the final file would be like following.

POSTCODE, LATITUDE, LONGITUDE

When I select "Layer > Open attribute table" I can see the "postcode" column.

I had a look at a similar question here

Getting list of coordinates for points in layer using QGIS?

Which told me to simply go to "Layer > Save as" and then type "GEOMETRY=AS_XY" or "GEOMETRY=AS_XYZ" in the "Layer" section of the "OGR creation options".

I followed exactly, but the latitude and longitude values are not being returned.

Best Answer

I see 2 solutions: 1st you could create 2 attributes to store your lon/lat:

  • select your layer
  • toggle to edit mode
  • open the attribute table
  • open the attribute calculator (ctrl+i)
  • name your column, choose the predefined geometry function $x, $y (in that dialog)

second solution (works for all gemetry types)

  • select your shp layer
  • save as ...
  • choose txt format
  • put GEOMETRY=AS_WKT in the OGR layer option

you will end up with a text file with the layer attributes and geometry as WKT

Related Question