I am trying to export a layer same to like this question: https://gis.stackexchange.com/a/435753/215676
But the difference is I'd like to do it in PyQGIS with QgsVectorFileWriter
. Is there a way to use that 'Use Key/Value' option in codes?
Here is my command which is not working:
QgsVectorFileWriter.writeAsVectorFormat(
layer,
outfile,
'utf-8',
QgsCoordinateReferenceSystem('EPSG:4326'),
'GeoJSON',
layerOptions=['COORDINATE_PRECISION=8'],
onlySelected=True
)
And I have this warning:
'DeprecationWarning: QgsVectorFileWriter.writeAsVectorFormat() is deprecated'
As I understand because of having those JSON fields, it works without JSON fields.