How to add new columns with attributes in existing Qgis layer? Doing the "same thing" here described

  • 2
    Welcome to GIS SE! Would you be able to use the edit button to expand upon your question, please? For example, at the moment it is hard to tell whether you have already used the QGIS documentation to learn how to add (and populate) new columns to QGIS layers. Also, how what you are after relates to your here described link looks like it needs to be made more explicit too. I think you may be saying that you want to do this "in memory", so I recommend saying that in this question. – PolyGeo Aug 20 '14 at 0:00

To add info to an existing layer instead of in memory layer you need to point to a layer on disk with QgsVectorLayer:

vl = QgsVectorLayer("C:\Temp\pt.shp", "pt", "ogr") 

Then you may continue to reference the code snippet from this Q/A:

How to create a new empty vector layer programmatically?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.