<div dir="ltr">Hi Even,<div><br></div><div>Thanks for you prompt answer!</div><div><br></div><div>Could you please point out a valid example on how to read/write a single byte raster dataset (preferably with a color table) in GPKG with any supported setup (tiling, format, padding etc)?</div><div><br></div><div>GTiff also can store different band count, padding, etc, but there isn't a similar problem with it. I'm not sure I understand the difference.  <br></div><div>So I'm not sure I understand the RGBA expansion you were talking about, do you have a link to more info on that matter? </div><div><br></div><div>Kind regards,</div><div>Idan</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 29 Oct 2018 at 14:29, Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On lundi 29 octobre 2018 14:19:12 CET Ben Avrahami wrote:<br>
> Hello, I'm trying to save a byte raster to a geopackage. I ran into a<br>
> problem that the geopackage raster driver does not behave as expected when<br>
> working with bytes and color tables. I have written a python script that<br>
> explains the issue (attached):<br>
> <br>
> The script creates 4 rasters in similar ways but prints different outputs:<br>
> <br>
> GTIFF(no palette):  Minimum=0, Maximum=9, Color Table=False, band count=1<br>
> GTIFF(palette):  Minimum=0, Maximum=9, Color Table=True, band count=1<br>
> GPKG(no palette):  Minimum=0, Maximum=9, Color Table=False, band count=4<br>
> GPKG(palette):  Minimum=0, Maximum=255, Color Table=False, band count=4<br>
> <br>
> The problem is that even though we set a color table in the geopackage when<br>
> writing, it reads as having no color table when reading. Worse yet, the<br>
> original raster values are lost when written with a color table.<br>
> <br>
> Is there any workaround or fix for this? We want to be able to keep<br>
> non-image byte data with a palette to geopackage.<br>
> <br>
<br>
Change<br>
ds = gdal.OpenEx(path, gdal.OF_READONLY)<br>
to<br>
ds = gdal.OpenEx(path, gdal.OF_READONLY, open_options=['BAND_COUNT=1'])<br>
<br>
if you know that all the tiles have a color table. Note: that will not work if <br>
your raster is made of a single tile that has some padding (which seems to be <br>
the case in your demo code), because the driver has to expand to RGBA to be <br>
able to fill transparent pixels.<br>
<br>
The fact that you don't get excatly the characteristics of the input dataset <br>
comes from the fact that GPKG can store tiles of different formats, band <br>
count, etc, so the driver defaults to exposing at RGBA as a safe setting<br>
<br>
-- <br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote></div>