Skip to content

Format support

This page lists the Cloud Optimized GeoTIFF files read by tileverse-cog, the files it rejects, and the rules of its collections, caches, and reads.

Accepted files

  • Tiled TIFF and BigTIFF, in either byte order.
  • With or without overviews.
  • With or without transparency masks, as written by GDAL next to the levels of a file with a mask.
  • With or without the GDAL ghost header. The layout is verified from the file itself in both cases.
  • Directories and index arrays placed before the tile data.

The module requires no georeferencing. CogImageSummary.geoKeys() tells whether a file has GeoTIFF keys, and epsgCode() reports the EPSG code they declare. pixelSize() reports the pixel size given by the pixel scale of the file or by its model transformation.

Rejected files

CogImage.open throws a CogVerificationException for a file breaking a layout rule. Its reason() is one of:

Reason The file
NOT_TIFF is not a TIFF or a BigTIFF: a bad byte order mark, magic number, or header.
STRIPPED is a stripped TIFF. Write it again with gdal_translate -of COG.
METADATA_AFTER_TILE_DATA has a directory or an index array at or after its tile data. Appending overviews to a tiled TIFF with gdaladdo produces such a file.
INCOMPATIBLE_EDITION declares KNOWN_INCOMPATIBLE_EDITION=YES in its ghost header: it was edited after it was written, and its layout cannot be relied on.
IFD_CHAIN_TOO_LONG has more than 64 directories, or a chain of directories looping back. Pyramids stay far below that count at any image size.
NO_TILE_OFFSETS has a directory without the tags of a tiled image, or holds only mask directories and no image.

Malformed files are rejected too, with a null reason(). Examples are a file cut short inside a directory, a directory missing a required tag, and a tag value ending past the end of the file. The message of the exception tells what is wrong. The same exception reports a tile index array ending past the end of the file, at the latest when a window reads that part of the index.

Compression

The module does not decompress tiles. That is the job of the decoder: the TIFF ImageReader found by CogWindow.read(), or your own. CogImageSummary.compressionName() names the compression of a file.

Compression With imageio-ext 2.1.4
None, Deflate, LZW, JPEG, ZSTD read, and covered by the tests of the module
PackBits, WebP, LERC, LZMA depends on the decoder and its plugins, not tested here

read() fails with the IOException of the decoder when the decoder does not know the compression, and with the unchecked StorageException of the storage when a tile fetch fails.

Tiles without data

With SPARSE_OK=TRUE, GDAL leaves out the tiles holding only nodata. The module fetches nothing for those tiles and leaves their pixels to the decoder.

  • With imageio-ext 2.1.4, such a tile reads as the nodata value declared by the file, or as zeros when the file declares none.
  • In an image of several bands interleaved by pixel, imageio-ext 2.1.4 writes a nodata value other than zero to part of the samples of the tile only. The others read as zeros, and which ones depends on the window.
  • Tiles without data are read under Deflate, ZSTD and PackBits. Under another compression the decoder cannot read a tile of no bytes, and CogImage.window fails with an IllegalArgumentException for a window over such a tile.

The decoder

CogWindow.read() asks the registered providers of TIFF readers whether they accept the TIFF stream of the window. It then creates one reader: the imageio-ext reader when its provider accepts the stream, otherwise the reader of the first accepting provider.

  • The stream is a BigTIFF. The TIFF reader of the JDK accepts classic TIFF only.
  • When no reader accepts the stream, read() fails with an IllegalStateException naming the artifact to add.
  • The module is tested with it.geosolutions.imageio-ext:imageio-ext-tiff 2.1.4.
  • imageio-ext removes the other TIFF readers from the ImageIO registry when it registers, the one of the JDK included.
  • The stream of a window is held in memory. Reading it writes no temporary file, whatever the cache setting of ImageIO.

Locations

CogLocation.parse(url, storageParams) classifies a URL without storage access. The rules apply in order, and the first matching rule decides.

The URL Is a Example
has a * Collection with a glob pattern s3://bucket/scenes/**/*.tif
ends in a slash, or names a bare bucket Collection of a directory s3://bucket/scenes/, s3://bucket
has a .tif or .tiff extension, or is an HTTP(S) URL SingleObject https://example.com/scene.tif
anything else Probed: an object or a directory, told by one metadata request s3://bucket/scenes
  • Plain HTTP(S) has no listing. parse rejects a glob or a directory on an HTTP(S) URL, unless the storage.provider parameter names the provider of the bucket behind it.
  • Globs use * and **. Braces and brackets are rejected in a URL with :// and in a glob pattern.
  • parse accepts a glob with a . or .. segment, and CogCollection.open fails on it.
  • The rules read a URL with :// without its query and fragment. The object is opened with the URL as given, and a presigned URL keeps its signature.
  • Local paths are accepted, with / or a Windows \ between their segments. A bare name is not a path: write ./scene.tif and ./*.tif for the working directory.

Collections

CogCollection.open lists a directory or a glob of a storage container.

  • The id of an item is its key relative to the container, extension included: 2024/scene.tif.
  • Directories list their direct children. Globs list the objects matching their pattern, in the folders crossed by the pattern.
  • Listings keep the objects with a .tif or .tiff extension, in any letter case.
  • Hidden objects, with a file name starting with a dot, are left out.
  • Object stores can hold keys with an empty segment (a//b.tif), with a . or .. segment, or with a backslash. Those keys are left out too.
  • list(maxEntries, maxItems) examines at most maxEntries entries, objects and folders alike, and stops once it has kept maxItems items. Both bounds must be at least 1.
  • CogListing.complete() is true when no entry follows the last one examined.
  • CogListing.folders() reports up to three folders seen and not searched by a directory listing.
  • find(id) makes one metadata request. It answers empty without a request for an id that no listing can produce: a hidden one, one without a TIFF extension, one with an empty segment, a dot segment or a backslash, or one outside the directory or the pattern.

CogCollection is an interface, and nothing in it assumes a folder of one storage. Ids are opaque strings unique within their collection. Items report an absolute URI and open themselves.

Caches

Cache Holds Setting
tileverse-cog-layout the directories of the objects read, with their tag values io.tileverse.cache.metadata.max-size, shared with the other metadata caches of the process
tileverse-cog-tile-index the chunks of the tile index arrays read for the windows of those objects same
byte ranges of the tiles kept by the storage, not by this module storage.caching.enabled

The two metadata caches are partitions of the metadata pool of the shared Tileverse CacheManager. Their entries are kept under the location, the version and the size of the object, and expire after thirty minutes without use. A replaced object has another version, and its directories are read again. An HTTP server refusing the metadata request gives no version: the size alone then tells a replaced object apart. CogCaches.clearAll() empties the caches of the shared CacheManager, including the caches of other modules.

Reads

Operation Reads from the storage
Open a file one metadata request for its size and version, then the first 64 KB block of the file, and the following blocks while its directories extend into them
Open a file with cached directories one metadata request, and no byte of the file
Read a window one batched read, for the tiles under it. The tile index of a large file is read in chunks, once per chunk
Read a window and its mask one batched read, for the tiles of both
Read a window again none: the window keeps its tiles
Read a window of more than 1,024 tiles the reads of the decoder, at least one per tile
Read the summary or the metadata stream none
CogCollection.list one request per page of entries examined
CogCollection.find one metadata request, or none for an id produced by no listing

Items of a collection open without the metadata request: their listing gave the size and the version.

A batched read is one call to the storage for several byte ranges. The storage decides how many requests to send for it. The object store and HTTP backends merge nearby ranges into shared requests and run them in parallel, as described in Read several ranges in one call.