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:
objectProvides read access to geospatial datasets.
A
DatasetReaderexposes the assets and metadata contained in a geospatial dataset (NITF, GeoTIFF, etc.) through a uniform interface. UseIO.open()with mode"r"to obtain an instance. The reader supports the Python context manager protocol, so resources are released automatically when thewithblock 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:
ImageAssetProviderfor images,TextAssetProviderfor text,DataAssetProviderfor structured data, orGraphicsAssetProviderfor 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:
- Returns:
Asset keys matching the filter criteria.
- Return type:
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.
- metadata¶
Dataset-level metadata as a
MetadataProvider.