Hi List,
I need to export the layers to a geopackage file, which also includes the
style defined in the layer. I have been reviewing documentation but I have
not been able to perform this task, this is part of the code I am using.
With this code I manage to create the geopackage file but it does not
include the style of the layer
def AddPostgisLayer_to_gpk(self):
uri = QgsDataSourceUri()
esquema = '25_hidrografia'
loadlayer = 'embalses'
GpName = r'd:\temp\embalses.gpkg'
firstt = True
options = QgsVectorFileWriter.SaveVectorOptions()
uri.setConnection("localhost", "5432", "bdsapromat", "postgres",
"postgres", QgsDataSourceUri.SslDisable)
uri.setDataSource(esquema, loadlayer, "geom", "geocodigo like " +
"'%-1'" )
uri.setSrid("4326")
vlayer = QgsVectorFileWriter(uri.uri(), loadlayer, "postgres")
options.layerName = loadlayer+"_puntual"
QgsVectorFileWriter.setSymbologyExport(vlayer,
QgsVectorFileWriter.SymbolLayerSymbology)
_writer = QgsVectorFileWriter.writeAsVectorFormat(vlayer, GpName,
options)
Regards, Frank
_______________________________________________
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