Tiler Factories
Tiler factories are helper functions that let users create a FastAPI router (fastapi.APIRouter
) with a minimal set of endpoints.
titiler.core.factory.TilerFactory
¶
from fastapi import FastAPI
from titiler.core.factory import TilerFactory
app = FastAPI(description="A lightweight Cloud Optimized GeoTIFF tile server")
cog = TilerFactory()
app.include_router(cog.router, tags=["Cloud Optimized GeoTIFF"])
Method | URL | Output | Description |
---|---|---|---|
GET |
/bounds |
JSON (Bounds) | return dataset's bounds |
GET |
/info |
JSON (Info) | return dataset's basic info |
GET |
/info.geojson |
GeoJSON (InfoGeoJSON) | return dataset's basic info as a GeoJSON feature |
GET |
/statistics |
JSON (Statistics) | return dataset's statistics |
POST |
/statistics |
GeoJSON (Statistics) | return dataset's statistics for a GeoJSON |
GET |
/tiles[/{tileMatrixSetId}]/{z}/{x}/{y}[@{scale}x][.{format}] |
image/bin | create a web map tile image from a dataset |
GET |
[/{tileMatrixSetId}]/tilejson.json |
JSON (TileJSON) | return a Mapbox TileJSON document |
GET |
[/{tileMatrixSetId}]/WMTSCapabilities.xml |
XML | return OGC WMTS Get Capabilities |
GET |
/point/{lon},{lat} |
JSON (Point) | return pixel values from a dataset |
GET |
/preview[.{format}] |
image/bin | create a preview image from a dataset (Optional) |
GET |
/crop/{minx},{miny},{maxx},{maxy}[/{width}x{height}].{format} |
image/bin | create an image from part of a dataset (Optional) |
POST |
/crop[/{width}x{height}][.{format}] |
image/bin | create an image from a GeoJSON feature (Optional) |
GET |
/map |
HTML | return a simple map viewer |
GET |
[/{tileMatrixSetId}]/map |
HTML | return a simple map viewer |
titiler.core.factory.MultiBaseTilerFactory
¶
Custom TilerFactory
to be used with rio_tiler.io.MultiBaseReader
type readers.
from fastapi import FastAPI
from rio_tiler.io import STACReader # rio_tiler.io.STACReader is a MultiBaseReader
from titiler.core.factory import MultiBaseTilerFactory
app = FastAPI(description="A lightweight STAC tile server")
cog = MultiBaseTilerFactory(reader=STACReader)
app.include_router(cog.router, tags=["STAC"])
Method | URL | Output | Description |
---|---|---|---|
GET |
/bounds |
JSON (Bounds) | return dataset's bounds |
GET |
/assets |
JSON | return the list of available assets |
GET |
/info |
JSON (Info) | return assets basic info |
GET |
/info.geojson |
GeoJSON (InfoGeoJSON) | return assets basic info as a GeoJSON feature |
GET |
/asset_statistics |
JSON (Statistics) | return per asset statistics |
GET |
/statistics |
JSON (Statistics) | return assets statistics (merged) |
POST |
/statistics |
GeoJSON (Statistics) | return assets statistics for a GeoJSON (merged) |
GET |
/tiles[/{tileMatrixSetId}]/{z}/{x}/{y}[@{scale}x][.{format}] |
image/bin | create a web map tile image from assets |
GET |
/[{tileMatrixSetId}]/tilejson.json |
JSON (TileJSON) | return a Mapbox TileJSON document |
GET |
/{tileMatrixSetId}/WMTSCapabilities.xml |
XML | return OGC WMTS Get Capabilities |
GET |
/point/{lon},{lat} |
JSON (Point) | return pixel values from assets |
GET |
/preview[.{format}] |
image/bin | create a preview image from assets (Optional) |
GET |
/crop/{minx},{miny},{maxx},{maxy}[/{width}x{height}].{format} |
image/bin | create an image from part of assets (Optional) |
POST |
/crop[/{width}x{height}][.{format}] |
image/bin | create an image from a geojson feature intersecting assets (Optional) |
GET |
[/{tileMatrixSetId}]/map |
HTML | return a simple map viewer |
titiler.core.factory.MultiBandTilerFactory
¶
Custom TilerFactory
to be used with rio_tiler.io.MultiBandReader
type readers.
from fastapi import FastAPI, Query
from rio_tiler_pds.landsat.aws import LandsatC2Reader # rio_tiler_pds.landsat.aws.LandsatC2Reader is a MultiBandReader
from titiler.core.factory import MultiBandTilerFactory
def SceneIDParams(sceneid: str = Query(..., description="Landsat Scene ID")) -> str:
"""Use `sceneid` in query instead of url."""
return sceneid
app = FastAPI(description="A lightweight Landsat Collection 2 tile server")
cog = MultiBandTilerFactory(reader=LandsatC2Reader, path_dependency=SceneIDParams)
app.include_router(cog.router, tags=["Landsat"])
Method | URL | Output | Description |
---|---|---|---|
GET |
/bounds |
JSON (Bounds) | return dataset's bounds |
GET |
/bands |
JSON | return the list of available bands |
GET |
/info |
JSON (Info) | return basic info for a dataset |
GET |
/info.geojson |
GeoJSON (InfoGeoJSON) | return basic info for a dataset as a GeoJSON feature |
GET |
/statistics |
JSON (Statistics) | return info and statistics for a dataset |
POST |
/statistics |
GeoJSON (Statistics) | return info and statistics for a dataset |
GET |
/tiles[/{tileMatrixSetId}]/{z}/{x}/{y}[@{scale}x][.{format}] |
image/bin | create a web map tile image from a dataset |
GET |
/[{tileMatrixSetId}]/tilejson.json |
JSON (TileJSON) | return a Mapbox TileJSON document |
GET |
/{tileMatrixSetId}/WMTSCapabilities.xml |
XML | return OGC WMTS Get Capabilities |
GET |
/point/{lon},{lat} |
JSON (Point) | return pixel value from a dataset |
GET |
/preview[.{format}] |
image/bin | create a preview image from a dataset |
GET |
/crop/{minx},{miny},{maxx},{maxy}[/{width}x{height}].{format} |
image/bin | create an image from part of a dataset |
POST |
/crop[/{width}x{height}][.{format}] |
image/bin | create an image from a geojson feature |
GET |
[/{tileMatrixSetId}]/map |
HTML | return a simple map viewer |
titiler.mosaic.factory.MosaicTilerFactory
¶
Method | URL | Output | Description |
---|---|---|---|
GET |
/ |
JSON MosaicJSON | return a MosaicJSON document |
GET |
/bounds |
JSON (Bounds) | return mosaic's bounds |
GET |
/info |
JSON (Info) | return mosaic's basic info |
GET |
/info.geojson |
GeoJSON (InfoGeoJSON) | return mosaic's basic info as a GeoJSON feature |
GET |
/tiles[/{tileMatrixSetId}]/{z}/{x}/{y}[@{scale}x][.{format}] |
image/bin | create a web map tile image from a MosaicJSON |
GET |
[/{tileMatrixSetId}]/tilejson.json |
JSON (TileJSON) | return a Mapbox TileJSON document |
GET |
[/{tileMatrixSetId}]/WMTSCapabilities.xml |
XML | return OGC WMTS Get Capabilities |
GET |
/point/{lon},{lat} |
JSON (Point) | return pixel value from a MosaicJSON dataset |
GET |
/{z}/{x}/{y}/assets |
JSON | return list of assets intersecting a XYZ tile |
GET |
/{lon},{lat}/assets |
JSON | return list of assets intersecting a point |
GET |
/{minx},{miny},{maxx},{maxy}/assets |
JSON | return list of assets intersecting a bounding box |
GET |
[/{tileMatrixSetId}]/map |
HTML | return a simple map viewer |
Important
Factories are built around rio_tiler.io.BaseReader
, which defines basic methods to access datasets (e.g COG or STAC). The default reader is COGReader
for TilerFactory
and MosaicBackend
for MosaicTilerFactory
.
Factories classes use dependencies injection to define most of the endpoint options.