In [ ]:
Copied!
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "async-pmtiles",
# "lonboard",
# "obstore",
# ]
# ///
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "async-pmtiles",
# "lonboard",
# "obstore",
# ]
# ///
Imports¶
In [ ]:
Copied!
from async_pmtiles import PMTilesReader
from obstore.store import HTTPStore
from lonboard import Map, RasterLayer
from async_pmtiles import PMTilesReader
from obstore.store import HTTPStore
from lonboard import Map, RasterLayer
Create PMTiles reader¶
Use the async-pmtiles library to create a new PMTilesReader.
Here we use Obstore to read data from a remote source. Obstore also lets you read data from AWS, Google Cloud Storage, Azure Storage, or local files.
Then we pass the path and store into PMTilesReader.open to instantiate a new reader.
In [ ]:
Copied!
store = HTTPStore("https://air.mtn.tw")
reader = await PMTilesReader.open("flowers.pmtiles", store=store)
store = HTTPStore("https://air.mtn.tw")
reader = await PMTilesReader.open("flowers.pmtiles", store=store)
Create RasterLayer from PMTiles source¶
Now we can create a new RasterLayer from this source, and display it on the map.
In [ ]:
Copied!
layer = RasterLayer.from_pmtiles(reader)
layer = RasterLayer.from_pmtiles(reader)
In [ ]:
Copied!
m = Map(layer)
m
m = Map(layer)
m
In [ ]:
Copied!