Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 attribute show in csv not geometry column. How can I export both attribute and spatial data into csv file.


share|improve this question
Here is the same question and the solution [link][1]. [1]:… – mete7 May 25 '13 at 15:00
I'm sorry for make question not clear. my work use python with pyqgis write vector layer to csv file. I want csv file have geometry but it not. still need answer – Anubiz May 26 '13 at 7:55
Depends on what type of vector layer you want to export. For point layer you could just add the lat, long values as attribute table columns. For all others you need WKT – Curlew May 26 '13 at 8:39
Thank you Curlew, I work with point and polygon layer. for point layer you mean add lat, lon column in attribute table? how about polygon? – Anubiz May 27 '13 at 8:39
Is this really a duplicate? This question here is aimed particularly at python, which is not covered by the linked answer. – Matthias Kuhn Jun 10 '13 at 8:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.