On Thu, 23 May 2019 at 02:02, matteo <[email protected]> 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
>
It's a rubbish error message. Blame sip. It should be saying:
"arguments did not match any overloaded call:
missing 1 required positional argument: 'fileEncoding'"
Because, as the dox show, fileEncoding is a required argument. And
indeed, this works fine for me:
error =
QgsVectorFileWriter.writeAsVectorFormat(layer=iface.activeLayer(),fileEncoding='UTF-8',fileName='/home/nyall/Temporary/test.geojson',driverName='GeoJSON')
Nyall
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer