Hi,

You should run the following considering you selected a vector layer

from qgis.core import QgsVectorFileWriter

layer = iface.activeLayer()
QgsVectorFileWriter.writeAsVectorFormat(layer, '/tmp/out.geojson', 'utf-8',
layer.crs(), 'GeoJSON', layerOptions=['RFC7946=True'])

Regards

Thomas Gratier


Le mer. 25 nov. 2020 à 18:47, PALMIER Patrick (Responsable de groupe) -
CEREMA/DTerNP/DATHa/MT <patrick.palm...@cerema.fr> a écrit :

> Hello,
>
> I'm using Qgis 3.14.16 with WIndows 10
>
> I'm trying in a python script to export a layer in geojSon with the
> option RFC7946=True
> It works well with the gui, but I don't know how to write it in a python
> script
> Is there someone who could send me a sample of code which do this
>
>
> Thanks
>
>
> Patrick
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to