RasterLayer¶
lonboard.RasterLayer ¶
The RasterLayer renders raster imagery.
This layer expects input such as Cloud-Optimized GeoTIFFs (COGs) that can be efficiently accessed by internal tiles.
debounce_time
class-attribute
instance-attribute
¶
debounce_time = tag(sync=True)
Queue tile requests until no new tiles have been added for at least debounceTime milliseconds.
If debounceTime == 0, tile requests are issued as quickly as the maxRequests concurrent request limit allows.
If debounceTime > 0, tile requests are queued until a period of at least debounceTime milliseconds has passed without any new tiles being added to the queue. May reduce bandwidth usage and total loading time during interactive view transitions.
- Default:
0
extent
class-attribute
instance-attribute
¶
extent = tag(sync=True)
The bounding box of the layer's data, in the form of [minX, minY, maxX, maxY].
If provided, the layer will only load and render the tiles that are needed to fill this box.
- Default:
null
max_cache_size
class-attribute
instance-attribute
¶
max_cache_size = tag(sync=True)
The maximum number of tiles that can be cached.
The tile cache keeps loaded tiles in memory even if they are no longer visible. It reduces the need to re-download the same data over and over again when the user pan/zooms around the map, providing a smoother experience.
If not supplied, the max_cache_size is calculated as 5 times the number of tiles
in the current viewport.
- Default:
null
max_zoom
class-attribute
instance-attribute
¶
max_zoom = tag(sync=True)
The max zoom level of the layer's data.
When overzoomed (i.e. zoom > maxZoom), tiles from this level will be displayed.
- Default:
null
min_zoom
class-attribute
instance-attribute
¶
min_zoom = tag(sync=True)
The min zoom level of the layer's data.
When underzoomed (i.e. zoom < minZoom), the layer will not display any tiles
unless extent is defined, to avoid issuing too many tile requests.
- Default: 0
tile_size
class-attribute
instance-attribute
¶
tile_size = tag(sync=True)
The pixel dimension of the tiles, usually a power of 2.
For geospatial viewports, tile size represents the target pixel width and height of each tile when rendered. Smaller tile sizes display the content at higher resolution, while the layer needs to load more tiles to fill the same viewport.
For non-geospatial viewports, the tile size should correspond to the true pixel size of the tiles.
- Default:
512
zoom_offset
class-attribute
instance-attribute
¶
zoom_offset = tag(sync=True)
This offset changes the zoom level at which the tiles are fetched. Needs to be an integer.
- Default:
0
from_pmtiles
classmethod
¶
from_pmtiles(
reader: PMTilesReader, **kwargs: Unpack[RasterLayerKwargs]
) -> RasterLayer[Buffer | None]
Create a RasterLayer from a PMTiles archive.
Example:
Using obstore.store.HTTPStore to read a PMTiles
file over HTTP:
from async_pmtiles import PMTilesReader
from lonboard import Map, RasterLayer
from obstore.store import HTTPStore
store = HTTPStore("https://air.mtn.tw")
reader = await PMTilesReader.open("flowers.pmtiles", store=store)
layer = RasterLayer.from_pmtiles(reader)
m = Map(layer)
Parameters:
-
reader(PMTilesReader) –A PMTilesReader instance from
async-pmtiles. Refer to theasync-pmtilesdocumentation for how to create a PMTilesReader from various input sources.
Other Parameters:
-
kwargs(Unpack[RasterLayerKwargs]) –parameters passed on to
__init__
Raises:
-
ValueError–if the PMTiles tile type is not a supported raster format (i.e. PNG, JPEG, WEBP, or AVIF).
Returns:
-
RasterLayer[Buffer | None]–A new RasterLayer instance.