
How to use TiTiler¶
Install¶
pip install httpx
Generate a tile URL and preview image¶
import httpx
titiler_endpoint = "https://titiler.services.eodc.eu"
asset_href = "https://data.eodc.eu/collections/BOA_LANDSAT_8/X0013_Y0014/20201231_LEVEL2_LND08_BOA.tif"
# Get a TileJSON with a tiles layer for use in a map application
r = httpx.get(
f"{titiler_endpoint}/cog/tilejson.json",
params={"url": asset_href, "rescale": "0,255", "bidx": 1, "bidx": 2, "bidx": 3},
).json()
# Generate a preview image of the data
r = httpx.get(
f"{titiler_endpoint}/cog/preview.png",
params={"url": asset_href, "rescale": "0,255", "bidx": 1, "bidx": 2, "bidx": 3},
)
Step by step:
asset_href— a direct URL to a Cloud-Optimized GeoTIFF (COG). You can obtain asset URLs from STAC items via the eodc STAC API./cog/tilejson.json— returns a TileJSON descriptor with an XYZ tile URL that you can plug into Leaflet, MapLibre, or QGIS./cog/preview.png— renders a small preview image of the full extent of the file.rescale— maps pixel value range to 0–255 for display. Adjust to match your dataset’s value range.bidx— selects which bands to render. Pass up to 3 band indices for an RGB composite.
Tips¶
TiTiler works with any publicly accessible COG, not just eodc data.
Use the
/cog/statisticsendpoint to inspect a file’s value range before choosingrescalevalues.The full TiTiler API is documented at
https://titiler.services.eodc.eu/docs.