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?