Skip to main content

GDAL-backed physical chunk model for the drb:image class

Project description

drb-chunk-image

GDAL-backed physical chunk model for the drb:image class, built on top of the drb-chunk add-on.

What it is

drb-chunk-image teaches drb-chunk how to read a GDAL raster (GeoTIFF, BigTIFF, COG, JP2, PNG, and any other format GDAL/rasterio can open) on its native block boundaries instead of on whatever grid a product descriptor happens to declare. It targets the generic drb:image topic class, not a single product family — it is the first format chunk add-on, sibling to the product-specific ones (drb-chunk-sentinel1, drb-chunk-sentinel2).

Concretely, it registers a PhysicalTilingProvider (gdal-blocks) that probes a raster's block layout — tile shape if the file is internally tiled, strip shape otherwise — via rasterio, without loading the full raster.

How it self-activates

Installing the package is enough; there is no product-side wiring:

  • It registers GdalBlocksProvider under the drb.chunk.physical entry-point group (drb.addons.chunk.image.provider:GdalBlocksProvider), the seam the drb-chunk core uses to discover physical-tiling providers lazily, and a matching raster physical reader via register_physical_reader.
  • It ships a cortex.ttl carrying a single triple — <http://www.gael.fr/drb#image> drb:physicalTiling "gdal-blocks" — declared under the drb.topic entry-point group. The core's ManagerDao merges every installed drb.topic descriptor into one RDF graph, so this triple lands on the existing drb:image topic without touching the driver or any other package.

Once both are installed, any chunk descriptor whose drb:source resolves to a GDAL-readable file automatically gets a physical chunk model: the core resolves the source's format topic, reads drb:physicalTiling, looks up gdal-blocks, and calls probe().

The two-layer model

drb-chunk separates the physical chunk model — the source's native chunking, discovered (never declared), the unit of I/O this add-on provides — from the logical chunk model — the output representation a product chunk declares (a regular N-D grid today; burst, and later healpix, for other formats). A chunk descriptor with no declared logical geometry (drb:chunkShape/drb:tilingScheme) simply adopts the physical grid as its logical grid. A descriptor that declares its own grid (e.g. a Sentinel-2 512×512 tile over a 1024×1024-tiled JP2) keeps that logical grid, but reads are still issued on the physical boundaries and remapped into the requested logical window — so adjacent logical tiles that share a native block only pay for that block once. probe() also accepts a multiplier (default 1), reserved for a future drb:nativeMultiplier descriptor predicate to request an exact multiple of the native block as the physical unit; it is not wired into the engine yet in this release. For untiled rasters (strips), the provider falls back to the strip band shape (rows_per_strip × width) — there is no "tile" to multiply.

Installation

pip install drb-chunk-image

Requires drb-chunk>=0.4.0,<1, rasterio and numpy (installed as dependencies).

Usage

No API of its own to call — once installed alongside drb-chunk, any product add-on's Chunk.select(...) over a GDAL-backed source picks up the physical model transparently:

from drb.topics import resolver
from drb.addons.addon import AddonManager
from drb.chunk.selection import WindowSelection

topic, node = resolver.resolve("/path/to/product.SAFE")
addon = AddonManager().get_addon("chunk")

chunk = addon.apply(node, chunk_name="B04_10m")   # e.g. drb-chunk-sentinel2
window = WindowSelection(x=0, y=0, w=512, h=512)
array = chunk.select(window).get_impl(numpy.ndarray)

Reads over B04_10m above are issued on the JP2's native block boundaries (e.g. 192×192), cached per source node, and remapped into the requested 512×512 window — not read once per 512×512 tile.

Limitations

  • Read-only probing: this add-on discovers the native chunking, it does not write or re-tile rasters.
  • Single reference band: block shape is probed from band 1 (ds.block_shapes[0]); mixed per-band block layouts are not modelled.
  • drb:nativeMultiplier is a reserved predicate, not yet read by the core engine — probe(node, multiplier=1) only ever runs with the default today.

Reference

See docs/dev/writing-a-physical-tiling-provider.md in drb-chunk for the PhysicalTilingProvider contract and how to write a provider for another format; this add-on is the reference implementation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drb_chunk_image-0.1.0.tar.gz (29.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drb_chunk_image-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file drb_chunk_image-0.1.0.tar.gz.

File metadata

  • Download URL: drb_chunk_image-0.1.0.tar.gz
  • Upload date:
  • Size: 29.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for drb_chunk_image-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0030711ed907a49126ce706ed00bb831b24fc2c836fd818fe5ce17ee391a8816
MD5 060a7dd4398a350de0aa64be4e74edc2
BLAKE2b-256 4d8cb2b451992894ef3897024004ee1adc6233f2d348df42ab5577bf5015add5

See more details on using hashes here.

File details

Details for the file drb_chunk_image-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for drb_chunk_image-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c27d924b188b7a4568dd006f824da3eec2e9df1e5a6d919584803e14de723101
MD5 c29e9274572cbedaa238dc40c86c9a78
BLAKE2b-256 0fe901d263642509e9e0e68cafd0b60a8f5bee1cef62691ee37bfa77a5518002

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page