Skip to content

API Documentation

async_pmtiles

async-pmtiles: asynchronous interface for reading PMTiles files.

PMTilesReader dataclass

An asynchronous PMTiles Reader.

bounds property

bounds: tuple[float, float, float, float]

The bounding box of the archive as (min_lon, min_lat, max_lon, max_lat).

center property

center: tuple[float, float, int]

The center of the archive as (center_lon, center_lat, center_zoom).

header instance-attribute

header: HeaderDict

The underlying raw PMTiles header metadata.

maxzoom property

maxzoom: int

The maximum zoom of the archive.

minzoom property

minzoom: int

The minimum zoom of the archive.

path instance-attribute

path: str

The path within the store to the PMTiles file.

store instance-attribute

store: Store

A reference to the store used for fetching byte ranges.

tile_compression property

tile_compression: Compression

Return the compression type used for tiles.

tile_type property

tile_type: TileType

Return the type of tiles contained in the archive.

get_tile async

get_tile(x: int, y: int, z: int) -> Buffer | None

Load data for a specific tile given its x, y, and z coordinates.

Note that no decompression is applied.

metadata async

metadata() -> dict

Load user-defined metadata stored in the PMTiles archive.

open async classmethod

open(path: str, *, store: Store) -> Self

Open a PMTiles file.

Parameters:

  • path (str) –

    The path within the store to the PMTiles file.

  • store (Store) –

    A generic "store" that implements fetching byte ranges asynchronously.

Raises:

  • ValueError

    If the PMTiles version is unsupported.

Returns:

  • Self

    An instance of PMTilesReader.

Store

Bases: Protocol

A generic protocol for accessing byte ranges of files.

This is compatible with obspec.GetRangeAsync and is implemented by obstore stores, such as S3Store, GCSStore, and AzureStore.

get_range_async async

get_range_async(path: str, *, start: int, length: int) -> Buffer

Asynchronously fetch a byte range from a file.

Parameters:

  • path (str) –

    The path to the file within the store.

  • start (int) –

    The starting byte offset of the range to fetch.

  • length (int) –

    The length of the range to fetch.

Returns:

  • Buffer

    Byte buffer.