<div dir="ltr"><div>Hi List,</div><div>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</div><div><br></div><div><br></div><div>Â def AddPostgisLayer_to_gpk(self):<br>Â Â Â Â uri = QgsDataSourceUri()<br>Â Â Â Â esquema = '25_hidrografia'<br>Â Â Â Â loadlayer = 'embalses'<br>Â Â Â Â GpName = r'd:\temp\embalses.gpkg'<br>Â Â Â Â firstt = True<br>Â Â Â Â options = QgsVectorFileWriter.SaveVectorOptions()<br>Â Â Â Â uri.setConnection("localhost", "5432", "bdsapromat", "postgres", "postgres", QgsDataSourceUri.SslDisable)<br>Â Â Â Â <br>Â Â Â Â uri.setDataSource(esquema, loadlayer, "geom", "geocodigo like " + "'%-1'" )<br>Â Â Â Â uri.setSrid("4326")<br>Â Â Â Â vlayer = QgsVectorFileWriter(uri.uri(), loadlayer, "postgres")<br>Â Â Â Â options.layerName = loadlayer+"_puntual"<br>Â Â Â Â QgsVectorFileWriter.setSymbologyExport(vlayer, QgsVectorFileWriter.SymbolLayerSymbology)<br>Â Â Â Â _writer = QgsVectorFileWriter.writeAsVectorFormat(vlayer, GpName, options)</div><div><br></div><div>
Regards, Frank<br></div></div>