Hi Devs,
I have tested this and it works
from qgis.core import QgsVectorLayer, QgsVectorFileWriter
ml = QgsVectorLayer('Point?field=firstfield:int&field=secondfield:int',
'test', 'memory')
filename = '/tmp/testing.gpkg'
options = QgsVectorFileWriter.SaveVectorOptions()
options.driverName = 'GPKG'
options.layerName = 'test'
write_result, error_message =
QgsVectorFileWriter.writeAsVectorFormat(ml,filename,options)
write_result == QgsVectorFileWriter.NoError
René-Luc
Le 23/05/2019 à 09:27, René-Luc Dhont a écrit :
Hi Dev,
I would like to create a geopackage with multiple layers but without
features. I'd like to do the same thing as the
QgsNewGeoPackageLayerDialog do but without user interface in python.
I have tested with QgsVectorFileWriter, but the file and layer are not
created if add feature is not used.
Do I have to use Python OGR packaging to do so ?
Regards,
René-Luc
_______________________________________________
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