Il 28/07/2022 18:32, Andrea Giudiceandrea ha scritto:
filepath = "[complete file path and file name and extension (.gpkg)]
lyrname = "test_layer"
fields=QgsFields()
fields.append(QgsField("test_field", QVariant.Double))
opts = QgsVectorFileWriter.SaveVectorOptions()
writer = QgsVectorFileWriter.create(filepath, fields, QgsWkbTypes.Point, QgsCoordinateReferenceSystem("EPSG:4326"), QgsCoordinateTransformContext(), opts)
del writer

...I forgot to add the layer name to the options...

filepath = "[complete file path and file name and extension (.gpkg)]
lyrname = "test_layer"
fields=QgsFields()
fields.append(QgsField("test_field", QVariant.Double))
opts = QgsVectorFileWriter.SaveVectorOptions()
opts.layerName = lyrname
writer = QgsVectorFileWriter.create(filepath, fields, QgsWkbTypes.Point, QgsCoordinateReferenceSystem("EPSG:4326"), QgsCoordinateTransformContext(), opts)
del writer
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to