[QGIS-Developer] QgsVectorFileWriter for GeoJSON

Alessandro Pasotti apasotti at gmail.com
Wed May 22 09:20:30 PDT 2019


Hi Matteo,

Did you try this?
https://qgis.org/pyqgis/master/core/QgsJsonExporter.html?highlight=json#module-QgsJsonExporter


On Wed, May 22, 2019 at 6:02 PM matteo <matteo.ghetta at gmail.com> wrote:

> Hi all,
>
> I cannot export a layer as GeoJSON using a very simple syntax:
>
> error = QgsVectorFileWriter.writeAsVectorFormat(layer=vl,
> fileName="/home/matteo/Desktop/my_json.geojson",
> driverName="GeoJSON")
>
> I always get an error like:
>
> TypeError: QgsVectorFileWriter.writeAsVectorFormat(): arguments did not
> match any overloaded call:
>   overload 1: 'driverName' is not a valid keyword argument
>   overload 2: 'driverName' is not a valid keyword argument
>   overload 3: 'driverName' is not a valid keyword argument
>
> while with:
>
> QgsVectorFileWriter.driverForExtension('.geojson') the output is:
>
> 'GeoJSON'
>
> and from the documentation driverName seems to be a keyword argument:
>
>
> https://qgis.org/pyqgis/master/core/QgsVectorFileWriter.html#qgis.core.QgsVectorFileWriter.writeAsVectorFormat
>
> with "ESRI Shapefile" it works correctly.
>
> Am I missing something?
>
> Cheers and thanks for all the hints
>
> Matteo
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Alessandro Pasotti
w3:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190522/f981f605/attachment.html>


More information about the QGIS-Developer mailing list