Media client#

class geonemo.client.MediaClient(
base_url=None,
*,
transport=None,
project_id=None,
token=None,
timeout=10.0,
client=None,
headers=None,
)#

Read only media selected by an authoritative catalog collection and record ID.

download(
collection,
record_id,
*,
byte_range=None,
max_bytes=16777216,
asset=None,
)#

Download a record’s source bytes into memory (GET /v1/media/records/{collection}/{record_id}/download).

Parameters:
  • collection – Catalog collection.

  • record_id – Record ID within the collection.

  • byte_range – Optional (start, end) byte range; end may be None for the rest.

  • max_bytes – Largest response accepted.

  • asset – Asset ID; defaults to the record’s primary asset.

Returns:

The bytes as MediaContent.

Raises:
download_to(
collection,
record_id,
destination,
*,
asset,
expected_byte_size,
expected_sha256,
expected_inventory_sha256=None,
expected_safe_relative_path=None,
resume=True,
chunk_size=1048576,
range_size=67108864,
)#

Stream a catalog asset to disk, verify it, and atomically publish it.

georeferenced_window(
collection,
record_id,
*,
x,
y,
width,
height,
output_width=None,
output_height=None,
bands=None,
max_bytes=16777216,
asset=None,
)#

Render a rectangular pixel window of a georeferenced record (GET /v1/media/records/{collection}/{record_id}/georeferenced-window).

Parameters:
  • collection – Catalog collection.

  • record_id – Record ID within the collection.

  • x – Left pixel column of the window.

  • y – Top pixel row of the window.

  • width – Window width in source pixels, 1 to 4096.

  • height – Window height in source pixels, 1 to 4096.

  • output_width – Rendered width in pixels, 1 to 4096; defaults to width.

  • output_height – Rendered height in pixels, 1 to 4096; defaults to height.

  • bands – One to three 1-based band numbers.

  • max_bytes – Largest response accepted.

  • asset – Asset ID; defaults to the record’s primary asset.

Returns:

The rendered window as MediaContent.

Raises:
histogram(
collection,
record_id,
*,
bins=64,
bands=None,
asset=None,
)#

Compute per-band histograms (GET /v1/media/records/{collection}/{record_id}/histogram).

Parameters:
  • collection – Catalog collection.

  • record_id – Record ID within the collection.

  • bins – Number of bins, 2 to 256.

  • bands – One to three 1-based band numbers; default is the service’s choice.

  • asset – Asset ID; defaults to the record’s primary asset.

Returns:

The MediaHistogram.

Raises:
inspect(collection, record_id, *, asset=None)#

Inspect a record’s raster (GET /v1/media/records/{collection}/{record_id}/inspect).

Parameters:
  • collection – Catalog collection.

  • record_id – Record ID within the collection.

  • asset – Asset ID to inspect; defaults to the record’s primary asset.

Returns:

The MediaInspection.

Raises:
pixel(collection, record_id, *, x, y, asset=None)#

Read the pixel values at one position (GET /v1/media/records/{collection}/{record_id}/pixel).

Parameters:
  • collection – Catalog collection.

  • record_id – Record ID within the collection.

  • x – Column, from 0.

  • y – Row, from 0.

  • asset – Asset ID; defaults to the record’s primary asset.

Returns:

The MediaPixel.

Raises:
preview(
collection,
record_id,
*,
max_width=1024,
max_height=1024,
bands=None,
stretch='percentile',
max_bytes=16777216,
asset=None,
)#

Render a bounded preview image (GET /v1/media/records/{collection}/{record_id}/preview).

Parameters:
  • collection – Catalog collection.

  • record_id – Record ID within the collection.

  • max_width – Maximum width in pixels, 32 to 2048.

  • max_height – Maximum height in pixels, 32 to 2048.

  • bands – One to three 1-based band numbers; default is the service’s choice.

  • stretch – Contrast stretch: percentile, minmax or none.

  • max_bytes – Largest response accepted.

  • asset – Asset ID; defaults to the record’s primary asset.

Returns:

The image as MediaContent.

Raises:
product_manifest(collection, record_id, *, page_size=500)#

Retrieve and validate every page of a product inventory.

product_manifest_page(
collection,
record_id,
*,
limit=100,
cursor=None,
)#

Return one deterministic page of an immutable product inventory.

tile(
collection,
record_id,
*,
z,
x,
y,
bands=None,
stretch='percentile',
max_bytes=16777216,
asset=None,
)#

Render one map tile (GET /v1/media/records/{collection}/{record_id}/tiles/{z}/{x}/{y}).

Parameters:
  • collection – Catalog collection.

  • record_id – Record ID within the collection.

  • z – Tile level, 0 to 24.

  • x – Tile column.

  • y – Tile row.

  • bands – One to three 1-based band numbers.

  • stretch – Contrast stretch: percentile, minmax or none.

  • max_bytes – Largest response accepted.

  • asset – Asset ID; defaults to the record’s primary asset.

Returns:

The tile image as MediaContent.

Raises: