Tuesday, 26 September 2017

fields attributes - Writing vector layer to CSV file with geometry using PyQGIS?


I use Python try to write vector layer file to csv file with this code:



QgsVectorFileWriter.writeAsVectorFormat(mylayer, r'c:\temp\xyz.csv', "utf-8", None, "CSV")

It can export to xyz.csv but only attributes show in the csv, not the geometry column.


How can I export both attribute and spatial data into csv file?




No comments:

Post a Comment