[QGIS-Developer] How to migrate the VectorWriter to Qgis3

Xavier Corredor Llano xavier.corredor.llano at gmail.com
Sun Jun 17 17:43:27 PDT 2018


On Saturday, 16 June 2018 20:39:29 -05 Nyall Dawson wrote:
> On Sat, 16 Jun 2018 at 02:36, Xavier Corredor Llano
> 
> <xavier.corredor.llano at gmail.com> wrote:
> > Hi Devs!
> > 
> > 
> > 
> > I have searched and I don't found any documentation about how to migrate
> > some functions inside processing tool, I use it inside my plugin (but
> > it's not a processing plugin inself) and I need to migrate specifically
> > the VectorWriter function for write a vector points file, such as:
> > 
> > 
> > 
> > from processing.tools import vector
> > 
> > 
> > 
> > writer = vector.VectorWriter(....)
> > 
> > ...
> > 
> > f = QgsFeature(...)
> > 
> > ...
> > 
> > writer.addFeature(f)
> 
> You should use the standard QgsVectorFileWriter class instead.
> 
> There's a bit of a guide to porting processing applications here:
> https://raw.githubusercontent.com/qgis/QGIS/master/doc/porting_processing.do
> x
> 
> Nyall

Thanks Nyall, It was good reference for read more the new api changes in processing 
functions, finally I migrated the VectorWriter like as:

from qgis.core import QgsVectorFileWriter, QgsWkbTypes

writer = QgsVectorFileWriter(output, "System", fields, QgsWkbTypes.MultiPoint, crs, "ESRI 
Shapefile")
f = QgsFeature(...)
writer.addFeature(f)

Regards,
Xavier Corredor Ll.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180617/05adb94b/attachment.html>


More information about the QGIS-Developer mailing list