[gdal-dev] Creating Cloud Optimized GeoTIFFs

Peter Schmitt pschmitt at gmail.com
Wed May 10 13:41:44 PDT 2017


Hi,

I ran into something confusing when using gdal-2.2.0 to generate Cloud
Optimized GeoTIFFs following the instructions at:
https://trac.osgeo.org/gdal/wiki/CloudOptimizedGeoTIFF

Here's what I did:

1. Fetch an image:
env CPL_VSIL_CURL_ALLOWED_EXTENSIONS=tif GDAL_DISABLE_READDIR_ON_OPEN=YES
VSI_CACHE=TRUE gdal_translate
https://github.com/mapbox/rasterio/raw/master/tests/data/RGB.byte.tif
rgb_byte_jpg.tif -co TILED=YES -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR

Not a cloud-optimized GeoTIFF as expected:

validate_cloud_optimized_geotiff.py  rgb_byte_jpg.tif
rgb_byte_jpg.tif is NOT a valid cloud optimized GeoTIFF : The file should
have overviews


2. Add internal overviews:
gdaladdo -r average rgb_byte_jpg.tif 2 4 8 16 32

validate_cloud_optimized_geotiff.py  rgb_byte_jpg.tif

rgb_byte_jpg.tif is NOT a valid cloud optimized GeoTIFF : The offset of the
first block of overview of index 3 should be after the one of the overview
of index 4


3.  Translate the image again copying source overviews added above.

gdal_translate rgb_byte_jpg.tif rgb_byte_jpg_trans.tif -co TILED=YES -co
COMPRESS=JPEG -co PHOTOMETRIC=YCBCR -co COPY_SRC_OVERVIEWS=YES

Now the image _is_ cloud-optimized.

validate_cloud_optimized_geotiff.py  rgb_byte_jpg_trans.tif
rgb_byte_jpg_trans.tif is a valid cloud optimized GeoTIFF


I expected the image to be "cloud optimized" at step 2.  Why do I need an
additional translate?


Notes:

* I see similar behavior for COMPRESS=DEFLATE.
* Thinking that the default block size (256) was too big for the tiny 25x23
overview, I set this on the initial translate, but I see the same behavior:
 -co BLOCKXSIZE=16 -co BLOCKYSIZE=16 --config GDAL_TIFF_OVR_BLOCKSIZE 16
* gdal-2.2.0 configured with "--with-libtiff=internal"
* Compiler::
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.5.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Thanks,
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170510/56c032be/attachment.html>


More information about the gdal-dev mailing list