<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>