async-pmtiles
An asynchronous PMTiles reader for Python.
The PMTiles format is a cloud-native, compressed, single-file archive for storing tiled vector and raster map data.
Documentation: https://developmentseed.org/async-pmtiles/
Install
pip install async-pmtiles
Example
from async_pmtiles import PMTilesReader
from obstore.store import HTTPStore
store = HTTPStore("https://r2-public.protomaps.com/protomaps-sample-datasets")
src = await PMTilesReader.open("cb_2018_us_zcta510_500k.pmtiles", store=store)
# PMTiles Metadata
meta = await src.metadata()
# Spatial Metadata
bounds = src.bounds
minzoom, maxzoom = src.minzoom, src.maxzoom
# Is the data a Vector Tile Archive
assert src.is_vector
# PMTiles tiles type
src.tile_type
# Tile Compression
src.tile_compression
# Get Tile
data = await src.get_tile(x=0, y=0, z=0)
Custom Client
Here's an example with using a small wrapper around aiohttp to read from arbitrary URLs:
from dataclasses import dataclass
from aiohttp import ClientSession
from async_pmtiles import PMTilesReader, Store
@dataclass
class AiohttpAdapter(Store):
session: ClientSession
async def get_range_async(
self,
path: str,
*,
start: int,
length: int,
) -> bytes:
inclusive_end = start + length - 1
headers = {"Range": f"bytes={start}-{inclusive_end}"}
async with self.session.get(path, headers=headers) as response:
return await response.read()
async def main():
async with ClientSession() as session:
store = AiohttpAdapter(session)
url = "https://r2-public.protomaps.com/protomaps-sample-datasets/cb_2018_us_zcta510_500k.pmtiles"
src = await PMTilesReader.open(url, store=store)
assert src.header
assert src.bounds == (-176.684714, -14.37374, 145.830418, 71.341223)
assert src.minzoom == 0
assert src.maxzoom == 7
Release files for async-pmtiles 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async_pmtiles-0.1.0.tar.gz | 5.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_pmtiles-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.6 kB
Release files / async_pmtiles-0.1.0.tar.gz
| Download URL | async_pmtiles-0.1.0.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
995c45bd19e9859e9a1668463b02c1d7b702467120adf4edd0cdba1cfd0d6bf8
|
|
BLAKE2b-256 checksum How to use checksums |
f9a8dda2094689ea38a5b2aa58b1ac7c9ee22bc2fad6f5a97c078030c541194d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / async_pmtiles-0.1.0-py3-none-any.whl
| Download URL | async_pmtiles-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
219a787c7a2c37f93f8e311f257686dbdfaaa5d9bfbf51dd511c70b016836498
|
|
BLAKE2b-256 checksum How to use checksums |
aa632fd3bc2a1e11d808cab5459f95b671ade84dd61e68f7bccd690da86032fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|