DatasetReader

A DatasetReader provides read access to a geospatial dataset and its assets.

Calling get_asset() returns a specialised provider whose type matches the asset’s category: ImageAssetProvider for images, TextAssetProvider for text, DataAssetProvider for structured data, or GraphicsAssetProvider for vector graphics.

class aws.osml.io.DatasetReader

Bases: object

Provides read access to geospatial datasets.

A DatasetReader exposes the assets and metadata contained in a geospatial dataset (NITF, GeoTIFF, etc.) through a uniform interface. Use IO.open() with mode "r" to obtain an instance. The reader supports the Python context manager protocol, so resources are released automatically when the with block exits.

Example:

```python from aws.osml.io import IO

with IO.open([“image.ntf”], “r”) as dataset:

image_keys = dataset.get_asset_keys(asset_type=”image”) print(f”Found {len(image_keys)} image assets”)

image = dataset.get_asset(image_keys[0]) print(type(image)) # ImageAssetProvider

```

close()

Releases all resources associated with this reader.

After calling this method, the reader should not be used.

get_asset(key)

Retrieve an asset by its unique key.

The returned object type depends on the asset’s type: ImageAssetProvider for images, TextAssetProvider for text, DataAssetProvider for structured data, or GraphicsAssetProvider for vector graphics.

Parameters:

key (str) – Unique string identifier for the asset.

Returns:

An asset provider whose concrete type matches the asset’s type.

Return type:

ImageAssetProvider | TextAssetProvider | DataAssetProvider | GraphicsAssetProvider

Raises:

KeyError – If no asset with the given key exists.

Example:

`python image = dataset.get_asset("image:0") `

get_asset_keys(asset_type=None, roles=None)

List asset keys, optionally filtered by type or roles.

Parameters:
  • asset_type (str, optional) – Restrict results to assets of this type (e.g., "image", "text", "data", "graphics").

  • roles (list[str], optional) – Restrict results to assets that have any of the specified roles.

Returns:

Asset keys matching the filter criteria.

Return type:

list[str]

Example:

`python image_keys = dataset.get_asset_keys(asset_type="image") text_keys = dataset.get_asset_keys(asset_type="text") `

has_asset(key)

Check whether an asset with the given key exists.

Parameters:

key (str) – Unique string identifier for the asset.

Returns:

True if the asset exists, False otherwise.

Return type:

bool

metadata

Dataset-level metadata as a MetadataProvider.