[Qgis-developer] vector writer : how to append new data to existing shapefile ?

Martin Dobias wonder.sk at gmail.com
Wed Dec 12 11:55:15 EST 2007


On Dec 12, 2007 5:43 PM, Michaël Douchin <michael.douchin at laposte.net> wrote:
>  In an short way "Is it possible to open a shapefile in write mode and then
> append some new data at the end" ?

Yes, that's possible too :-)

You can open your shapefile as a vector layer and then use its
provider to add some features:
layer = QgsVectorLayer(...)
provider = layer.getDataProvider()
provider.addFeatures( [ feature ] )

And that's it. I didn't try it now but should work as expected.
addFeatures() expects list of features, but of course you can add them
one by one.

Martin



More information about the Qgis-developer mailing list