7.6.2 Raster data - Geographic data I/O | Geocomputation with Python (geocompx.org)
Raster drivers | GDAL docs (gdal.org)
with rasterio.open(
'/tmp/new.gpkg',
'w',
driver='GPKG',
height=Z.shape[0],
width=Z.shape[1],
count=1,
dtype=Z.dtype,
crs='+proj=latlong',
transform=transform,
) as dst:
dst.write(Z, 1)