<div dir="ltr">Hi Even,<div><br></div><div>This is great news ! I will check it out as soon as I can.<br>Thanks</div><div>Philippe</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 8, 2024 at 1:07 PM Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<p>Hi Philippe,</p>
<p>I no longer reproduce the below issues nor
<a href="https://github.com/OSGeo/gdal/issues/3853" target="_blank">https://github.com/OSGeo/gdal/issues/3853</a> with gdaladdo without
explicit level with GDAL master 3.9dev. This is due to improvement
<a href="https://github.com/OSGeo/gdal/commit/d178b03e3db" target="_blank">https://github.com/OSGeo/gdal/commit/d178b03e3db</a> that reuse
existing overview levels when they are declared by the dataset.
Which is the case for a GeoPackage created with a tiling_scheme
and with unpopulated levels.</p>
<p>The only case now where the tiling scheme might no longer be
respected is if the user specifies an overview level beyond the
base one, or some "weird" factor like 3. But as it is the user
that requests that, I don't think we should do anything for that
case.</p>
<p>Even<br>
</p>
<div>Le 08/01/2024 à 11:57, Philippe
Ghesquiere via gdal-dev a écrit :<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div><span style="color:rgb(94,94,94);font-family:"Google Sans",Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">Dear
all,</span></div>
<div><span style="color:rgb(94,94,94);font-family:"Google Sans",Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px"> A
while ago, I opened a ticket which is still opened (</span><a href="https://github.com/OSGeo/gdal/issues/3853" target="_blank">https://github.com/OSGeo/gdal/issues/3853</a>)<span style="color:rgb(94,94,94);font-family:"Google Sans",Roboto,RobotoDraft,Helvetica,Arial,sans-serif;font-size:14px">.
I recently bumped into this bug with some new data, and I
think I tracked the origin.</span></div>
<div><br>
</div>
<div><br>
</div>
<div><u>1) Generate a test image :</u><br>
gdal_create -of GTIFF -co COMPRESS=LZW -a_srs epsg:4326
-a_ullr -180 90 180 -90 -burn 128 -outsize 2048 1024
worldwide.tif<br>
<br>
</div>
<div><u>2) Convert to GPKG :</u><br>
gdal_translate -of GPKG -co TILING_SCHEME=InspireCRS84Quad
worldwide.tif worldwide_no_pyramid.gpkg<br>
<br>
The GPKG tile matrix is as expected : <br>
sqlite3 -header -column worldwide_no_pyramid.gpkg "SELECT
rowid,* FROM gpkg_tile_matrix ;"<br>
rowid table_name zoom_level matrix_width
matrix_height tile_width tile_height pixel_x_size
pixel_y_size<br>
----- -------------------- ---------- ------------
------------- ---------- ----------- ------------
------------<br>
1 worldwide_no_pyramid 0 2 1
256 256 0.703125 0.703125<br>
2 worldwide_no_pyramid 1 4 2
256 256 0.3515625 0.3515625<br>
3 worldwide_no_pyramid 2 8 4
256 256 0.17578125 0.17578125<br>
<br>
<u>3) Compute a default pyramid:</u><br>
cp worldwide_no_pyramid.gpkg worldwide_default_pyramid.gpkg<br>
gdaladdo worldwide_default_pyramid.gpkg</div>
<div><br>
The GPKG tile matrix is no longer the expected one
(InspireCRS84Quad InspireCRS84Quad) :<br>
sqlite3 -header -column worldwide_default_pyramid.gpkg
"SELECT rowid,* FROM gpkg_tile_matrix ;"<br>
rowid table_name zoom_level matrix_width
matrix_height tile_width tile_height pixel_x_size
pixel_y_size<br>
----- -------------------- ---------- ------------
------------- ---------- ----------- ------------
------------<br>
1 worldwide_no_pyramid 1 2 1
256 256 0.703125 0.703125<br>
2 worldwide_no_pyramid 2 4 2
256 256 0.3515625 0.3515625<br>
3 worldwide_no_pyramid 3 8 4
256 256 0.17578125 0.17578125<br>
4 worldwide_no_pyramid 0 1 1
256 256 1.40625 1.40625<br>
<br>
</div>
<div><u>4) Compute a manual pyramid:</u><br>
cp worldwide_no_pyramid.gpkg worldwide_manual_pyramid.gpkg<br>
gdaladdo worldwide_manual_pyramid.gpkg 2 4<br>
<br>
</div>
<div>The GPKG tile matrix is still as expected (InspireCRS84Quad
InspireCRS84Quad) : <br>
sqlite3 -header -column worldwide_manual_pyramid.gpkg "SELECT
rowid,* FROM gpkg_tile_matrix ;"<br>
rowid table_name zoom_level matrix_width
matrix_height tile_width tile_height pixel_x_size
pixel_y_size<br>
----- -------------------- ---------- ------------
------------- ---------- ----------- ------------
------------<br>
1 worldwide_no_pyramid 0 2 1
256 256 0.703125 0.703125<br>
2 worldwide_no_pyramid 1 4 2
256 256 0.3515625 0.3515625<br>
3 worldwide_no_pyramid 2 8 4
256 256 0.17578125 0.17578125<br>
<br>
</div>
<div><u>5) Compute a "Weird" pyramid:</u><br>
In this test, I generate too many levels in the pyramid on
purpose :<br>
cp worldwide_no_pyramid.gpkg
worldwide_manual_weird_pyramid.gpkg<br>
gdaladdo worldwide_manual_weird_pyramid.gpkg 2 4 8<br>
<br>
</div>
<div>The GPKG tile matrix is exactly the same as in
worldwide_default_pyramid.gpkg :<br>
sqlite3 -header -column worldwide_manual_weird_pyramid.gpkg
"SELECT rowid,* FROM gpkg_tile_matrix ;"<br>
rowid table_name zoom_level matrix_width
matrix_height tile_width tile_height pixel_x_size
pixel_y_size<br>
----- -------------------- ---------- ------------
------------- ---------- ----------- ------------
------------<br>
1 worldwide_no_pyramid 1 2 1
256 256 0.703125 0.703125<br>
2 worldwide_no_pyramid 2 4 2
256 256 0.3515625 0.3515625<br>
3 worldwide_no_pyramid 3 8 4
256 256 0.17578125 0.17578125<br>
4 worldwide_no_pyramid 0 1 1
256 256 1.40625 1.40625<br>
<br>
<u>6) Conclusion </u><br>
The default power-of-two factor list is computed in
gdaladdo.cpp. At this point, the algorithm is not aware of
some GPKG limitations.<br>
<br>
I found two workarounds :<br>
<ul>
<li>specify explicitly all zoom levels</li>
<li>add minsize option. The minimum size has to be twice the
tile_height / tile_width : -minsize 512</li>
</ul>
Shouldn't we have a specific check for GPKG while computing
the pyramid ? For example by deriving the virtual method
BuildOverviews() for GPKG ?<br>
</div>
<div><br>
</div>
<div>Philippe</div>
<div><br>
</div>
</div>
<font style="font-size:9px">The information in this e-mail is
confidential. The contents may not be disclosed or used by
anyone other than the addressee. Access to this e-mail by anyone
else is unauthorised.<br>
If you are not the intended recipient, please notify Airbus
immediately and delete this e-mail.<br>
Airbus cannot accept any responsibility for the accuracy or
completeness of this e-mail as it has been sent over public
networks. If you have any concerns over the content of this
message or its Accuracy or Integrity, please contact Airbus
immediately.<br>
All outgoing e-mails from Airbus are checked using regularly
updated virus scanning software but you should take whatever
measures you deem to be appropriate to ensure that this message
and any attachments are virus free.</font><br>
<fieldset></fieldset>
<pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre cols="72">--
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</div>
</blockquote></div>
<font style="font-size: 9px;">The information in this e-mail is confidential. The contents may not be disclosed or used by anyone other than the addressee. Access to this e-mail by anyone else is unauthorised.<br>If you are not the intended recipient, please notify Airbus immediately and delete this e-mail.<br>Airbus cannot accept any responsibility for the accuracy or completeness of this e-mail as it has been sent over public networks. If you have any concerns over the content of this message or its Accuracy or Integrity, please contact Airbus immediately.<br>All outgoing e-mails from Airbus are checked using regularly updated virus scanning software but you should take whatever measures you deem to be appropriate to ensure that this message and any attachments are virus free.</font>