<div dir="ltr">Hello, I'm trying to use GDAL python API to work with geopackage files, and I ran into some trouble<div><br></div><div>First off, when creating a geopackage raster, the created raster is always 4-bands. After running this code:</div><div><br></div><div><blockquote style="font-family:"Courier New";font-size:9pt"><span style="background-color:rgb(255,255,255)"><font color="#000000">import ogr, osr, gdal<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">import numpy as np</font></span><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">dst_path = 'out.gpkg'<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">srs = osr.SpatialReference()<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">srs.ImportFromEPSG(4326)</font></span><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">options = ()<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">driver = gdal.GetDriverByName('GPKG')</font></span><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">dst_ds = driver.Create(dst_path, 19, 10, 1, options=options)<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">dst_ds.SetGeoTransform((30, 0.01, 0.0, 30, 0.0, -0.01))<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">dst_ds.SetProjection(srs.ExportToWkt())<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">band = dst_ds.GetRasterBand(1)</font></span><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">array = np.array([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">                  [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">band.WriteArray(array)<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">band.FlushCache()</font></span><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">assert dst_ds.RasterCount == 1<br></font></span><span style="background-color:rgb(255,255,255)"><font color="#000000">del dst_ds</font></span></blockquote><pre style="font-family:"Courier New";font-size:9pt"><pre style="font-family:"Courier New";font-size:9pt"><pre style="font-family:"Courier New";font-size:9pt"><span style="background-color:rgb(255,255,255)"><font color="#000000"><br></font></span></pre><pre style="font-family:"Courier New";font-size:9pt">I get a 4-band raster (weirdly enough, with all RGB bands set to the set value, and the ALPHA set 255)</pre><pre style="font-family:"Courier New";font-size:9pt"><br></pre><pre style="font-family:"Courier New";font-size:9pt">Second, the API has no mention as to how to work with the geopackage to save/load multiple raster layers and vector layers simultaneously.</pre><pre style="font-family:"Courier New";font-size:9pt">All my attempts at creating a geopackage file with both a raster layer and a vector layer have failed, either with the vector layer not appearing or standard errors.</pre><pre style="font-family:"Courier New";font-size:9pt"><br></pre><pre style="font-family:"Courier New";font-size:9pt">Any help at all would be appreciated, thank you.</pre></pre></pre></div></div>