4

These questions have been asked before, but since they are not answered I will try to pick up the ends here.

1) First, as stated here:

QGIS 2.2 saving layer as CSV with GEOMETRY=AS_WKT not working

in Qgis 2.2 it is not possible to save a shapefile as .csv including the coordinates using the function _GEOMETRY=AS_WKT_. The issue

http://hub.qgis.org/issues/9597

is set to closed. Does it mean that it has been fixed? And if so, how to make it work again?

2) Second, if you want to save a shape file as .csv with coordinates through PyQgis it can be done with:

https://gis.stackexchange.com/questions/61857/how-to-write-vector-layer-to-csv-file-with-geometry-by-python 

as stated here:

How to write vector layer to csv file with geometry by PYTHON?

But again, this does not save the coordinates, and I can't find any solution to this either. So right now, I still have to use an old version on QGIS.

IS there any solutions to these, available at the moment?

6
  • The bug is fixed in current master, available as qgis-dev in the Osgeo4W setup, or by building from source. It will be available to all in QGIS 2.4. Commented Apr 15, 2014 at 7:05
  • Ok, good to know. So at the moment in QGIS 2.2 it is not possible to save a shape file with coordinates to .csv via python console? Commented Apr 15, 2014 at 8:13
  • Only with the mmqgis plugin. Commented Apr 15, 2014 at 8:46
  • How do you call mmqgis's Geometry export to CSV from the console? I cant find any documentation on it. Commented Apr 15, 2014 at 9:52
  • Sorry, I don't use the console. Commented Apr 15, 2014 at 10:16

1 Answer 1

4

In PYQGIS a shape file can be save as a .csv with coordinates by:

QgsVectorFileWriter.writeAsVectorFormat(vlayer, "xy.csv", "utf-8", None, "CSV", layerOptions ='GEOMETRY=AS_WKT') 

This is not working in QGIS 2.2 but will work again in QGIS 2.4.

1
  • use layerOptions =['GEOMETRY=AS_WKT'] in QGIS 2.18 Commented Apr 9, 2018 at 12:11

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.