With the following code I can save a raster layer as geopackage:
<code>lyr = iface.activeLayer()
outPath = r"D:test.gpkg"
fileWriter = QgsRasterFileWriter(outPath)
pipe = QgsRasterPipe()
pipe.set(lyr.dataProvider().clone())
fileWriter.writeRaster(pipe, lyr.width(), lyr.height(), lyr.extent(), lyr.crs())
</code>
<code>lyr = iface.activeLayer()
outPath = r"D:test.gpkg"
fileWriter = QgsRasterFileWriter(outPath)
pipe = QgsRasterPipe()
pipe.set(lyr.dataProvider().clone())
fileWriter.writeRaster(pipe, lyr.width(), lyr.height(), lyr.extent(), lyr.crs())
</code>
lyr = iface.activeLayer()
outPath = r"D:test.gpkg"
fileWriter = QgsRasterFileWriter(outPath)
pipe = QgsRasterPipe()
pipe.set(lyr.dataProvider().clone())
fileWriter.writeRaster(pipe, lyr.width(), lyr.height(), lyr.extent(), lyr.crs())
How do I adjust this code to add to an existing geopackage rather than creating one?
I am aware that there is a workaround using processing/gdal (stackexchange). But my question is specifically for the QgsRasterFileWriter.