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

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...