Skip to content

Dynamic tiling

datacube_benchmark.titiler.tiling_benchmark_summary

tiling_benchmark_summary(df)

Compute and (optionally) print summary statistics for tile benchmark results. Groups by zoom level and reports: - n_tiles - ok_pct, no_data_pct, error_pct - median_latency_s, p95_latency_s

Parameters:

  • df (DataFrame) –

    Raw per-tile results with at least zoom ok, and response_time_sec.

Returns:

  • DataFrame

    Summary statistics by zoom level (count, median, p95, etc.).

datacube_benchmark.titiler.TiTilerCMRBenchmarker

Bases: BaseBenchmarker

Main benchmarking utility for TiTiler-CMR. Supports benchmarking of tile rendering and statistics endpoints across different strategies (viewport, tileset, custom).

benchmark_statistics async

benchmark_statistics(
    dataset: DatasetParams,
    geometry: Optional[Union[Feature, Dict[str, Any]]] = None,
    **kwargs: Any,
) -> Dict[str, Any]

Benchmark statistics endpoint performance with timing and memory metrics.

Parameters:

  • dataset (DatasetParams) –

    Dataset configuration.

  • geometry (Union[Feature, Dict[str, Any]], default: None ) –

    GeoJSON Feature or geometry to analyze. If None, uses bounds from tilejson.

  • **kwargs (Any, default: {} ) –

    Additional query parameters.

Returns:

  • Dict[str, Any]

    Statistics result with timing, memory, and metadata.

benchmark_tiles async

benchmark_tiles(
    dataset: DatasetParams,
    tiling_strategy: Callable,
    warmup_per_zoom: int = 1,
    **kwargs: Any,
) -> DataFrame

Benchmark tile rendering performance for TiTiler-CMR. It can be adopted for a viewport or whole tileset generation at a zoom level.

Parameters:

  • dataset (DatasetParams) –

    Dataset and query parameters (concept_id, backend, datetime_range, kwargs).

  • tiling_strategy (Callable) –

    Function that returns tiles for a given zoom level. Signature: (zoom, tms, tilejson_info) -> List[Tuple[int, int]]

  • warmup_per_zoom (int, default: 1 ) –

    Number of warmup tiles to fetch per zoom level before timing. Default is 1.

  • **kwargs (Any, default: {} ) –

    Additional query parameters for the API.

Returns:

  • DataFrame

    Results for each tile request, including status, latency, and size.

datacube_benchmark.titiler.DatasetParams dataclass

Encapsulates parameters for requesting tiles from TiTiler-CMR.

Required: concept_id (str): CMR concept ID for the dataset. backend (str): Backend type, e.g., "xarray" or "rasterio". datetime_range (str): ISO8601 interval, e.g., "2024-10-01T00:00:00Z/2024-10-10T00:00:00Z".

Optional (backend-dependent): variable (str): For xarray backend, the variable name. bands (Sequence[str]): For rasterio backend, list of bands. bands_regex (str): For rasterio backend, regex for band selection. rescale (str): Rescale range for visualization. colormap_name (str): Colormap name for visualization. resampling (str): Resampling method. step (str): Temporal stepping, e.g., "P1D". temporal_mode (str): Temporal aggregation mode, e.g., "point". minzoom (int): Minimum zoom level. maxzoom (int): Maximum zoom level. tile_format (str): Output tile format. tile_scale (int): Tile scaling factor. others: Extend as needed.

Raises: ValueError: If required backend-specific fields are missing.

to_query_params

to_query_params(**extra_kwargs: Any) -> List[Tuple[str, str]]

Convert dataset parameters into query parameters for TiTiler-CMR.

Combines required fields and all additional keyword arguments, filtering out None values and converting types as needed.

Raises: ValueError: If required backend-specific fields are missing.

datacube_benchmark.titiler.get_surrounding_tiles

get_surrounding_tiles(
    center_x: int, center_y: int, zoom: int, width: int, height: int
) -> list[tuple[int, int]]

Get a list of surrounding tile coordinates for a viewport around (center_x, center_y). This function builds a width × height viewport centered on the given tile at the specified zoom level. from github.com/developmentseed/titiler-cmr/blob/develop/tests/test_hls_benchmark.py

Parameters:

  • center_x (int) –

    X index of the center tile.

  • center_y (int) –

    Y index of the center tile.

  • zoom (int) –

    WebMercator zoom level.

  • width (int) –

    Viewport width in tiles.

  • height (int) –

    Viewport height in tiles.

Returns:

  • list of tuple of int

    List of (x, y) tile indices covering the viewport (row-major order).

datacube_benchmark.titiler.fetch_tile async

fetch_tile(
    client: AsyncClient,
    *,
    tiles_endpoints: List[str],
    z: int,
    x: int,
    y: int,
    timeout_s: float = 30.0,
    proc: Optional[Process] = None,
) -> List[Dict[str, Any]]

For a single (z,x,y), iterate over all tiles endpoints, GET the tile, print status, and return one record per request.

Parameters:

  • client (AsyncClient) –

    The HTTP client to use for requests.

  • tiles_endpoints (list of str) –

    URL templates containing {z}, {x}, and {y}.

  • z (int) –

    Tile coordinates.

  • x (int) –

    Tile coordinates.

  • y (int) –

    Tile coordinates.

  • timeout_s (float, default: 30.0 ) –

    Per-request timeout (seconds).

  • proc (Process, default: None ) –

    Process to sample RSS.

Returns:

  • List[Dict[str, Any]]

    One dictionary per endpoint with fields: zoom/z/x/y, timestep_index, url, status_code, ok, no_data, is_error, ttfb_sec, transfer_time_sec, response_time_sec, response_size_bytes, content_type, error_text, rss_delta, sched_delay_sec (if started_at provided)

datacube_benchmark.titiler.get_tileset_tiles

get_tileset_tiles(
    bounds: List[float], zoom: int, tms: TileMatrixSet
) -> List[Tuple[int, int]]

Get all tiles for a complete zoom level within bounds.

Parameters:

  • bounds (List[float]) –

    Bounding box [minx, miny, maxx, maxy] in CRS coordinates

  • zoom (int) –

    Zoom level

  • tms (TileMatrixSet) –

    Tile matrix set

Returns:

datacube_benchmark.titiler.create_bbox_feature

create_bbox_feature(
    minx: float, miny: float, maxx: float, maxy: float
) -> Feature

Create a GeoJSON Feature from bounding box coordinates.

Parameters:

  • minx (float) –

    Bounding box coordinates.

  • miny (float) –

    Bounding box coordinates.

  • maxx (float) –

    Bounding box coordinates.

  • maxy (float) –

    Bounding box coordinates.

Returns:

  • Feature

    GeoJSON Feature representing the bounding box.