Skip to content

Module stac_fastapi.core.utilities

Module for geospatial processing functions.

This module contains functions for transforming geospatial coordinates, such as converting bounding boxes to polygon representations.

Variables

MAX_LIMIT

Functions

bbox2polygon

def bbox2polygon(
    b0: float,
    b1: float,
    b2: float,
    b3: float
) -> list[list[list[float]]]

Transform a bounding box represented by its four coordinates b0, b1, b2, and b3 into a polygon.

Parameters:

Name Type Description Default
b0 float The x-coordinate of the lower-left corner of the bounding box. None
b1 float The y-coordinate of the lower-left corner of the bounding box. None
b2 float The x-coordinate of the upper-right corner of the bounding box. None
b3 float The y-coordinate of the upper-right corner of the bounding box. None

Returns:

Type Description
List[List[List[float]]] A polygon represented as a list of lists of coordinates.

dict_deep_update

def dict_deep_update(
    merge_to: dict[str, typing.Any],
    merge_from: dict[str, typing.Any]
) -> None

Perform a deep update of two dicts.

merge_to is updated in-place with the values from merge_from. merge_from values take precedence over existing values in merge_to.

filter_fields

def filter_fields(
    item: stac_fastapi.types.stac.Item | dict[str, typing.Any],
    include: set[str] | None = None,
    exclude: set[str] | None = None
) -> stac_fastapi.types.stac.Item

Preserve and remove fields as indicated by the fields extension include/exclude sets.

Returns a shallow copy of the Item with the fields filtered.

This will not perform a deep copy; values of the original item will be referenced in the return item.

get_bool_env

def get_bool_env(
    name: str,
    default: bool | str = False
) -> bool

Retrieve a boolean value from an environment variable.

Parameters:

Name Type Description Default
name str The name of the environment variable. None
default bool str The default value to use if the variable is not set or unrecognized. Defaults to False.

Returns:

Type Description
bool The boolean value parsed from the environment variable.

get_excluded_from_items

def get_excluded_from_items(
    obj: dict,
    field_path: str
) -> None

Remove a field from items.

The field is removed in-place from the dictionary if it exists. If any intermediate path does not exist or is not a dictionary, the function returns without making any changes.