Skip to content

Resources

Each endpoint group is a wrapper reached through MermaidClient or, for the project-scoped routes, through ProjectContext. See Working with data and Project data for how they are used.

Shared plumbing

base

Shared plumbing for endpoint wrappers.

Classes:

Name Description
BaseResource

Anything reachable through the client: a path and a way to request it.

Resource

Base class for endpoints returning records of one model.

ReadOnlyResource

A read-only endpoint: a paginated list plus a /<id>/ detail route.

Functions:

Name Description
project_path

Compose projects/<project_id>/<route>.

BaseResource

BaseResource(client: MermaidClient)

Anything reachable through the client: a path and a way to request it.

Endpoints whose responses are not lists of models (/choices/) extend this directly; everything else extends Resource.

Attributes:

Name Type Description
path str
path instance-attribute
path: str

Resource

Resource(client: MermaidClient)

Bases: BaseResource, Generic[M]

Base class for endpoints returning records of one model.

Subclasses set path and model and expose whatever public methods make sense for the endpoint, built on _list and _get.

Attributes:

Name Type Description
model type[M]
path str
model instance-attribute
model: type[M]
path instance-attribute
path: str

ReadOnlyResource

ReadOnlyResource(client: MermaidClient)

Bases: Resource[M]

A read-only endpoint: a paginated list plus a /<id>/ detail route.

Reference endpoints differ only in their path and model, so they subclass this and declare those two attributes.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path str
model type[M]
path instance-attribute
path: str
model instance-attribute
model: type[M]
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

project_path

project_path(project_id: str, route: str) -> str

Compose projects/<project_id>/<route>.

The id is percent-encoded, so a stray / or .. in it cannot send the request to a different endpoint.

Projects

projects

The /projects/ endpoints.

Classes:

Name Description
ProjectsResource

Read access to MERMAID projects.

ProjectsResource

ProjectsResource(client: MermaidClient)

Bases: ReadOnlyResource[Project]

Read access to MERMAID projects.

Filters: showall (include projects the credentials are not a member of), name, country, tags, status.

Calling the resource with a project id (or a Project) returns a ProjectContext, the handle on everything recorded under that project.

Example
client.projects.get(project_id)  # the project record itself
client.projects(project_id).sites.list()  # what is recorded under it
client.projects(client.projects.get(project_id))  # either works

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'projects/'
model class-attribute instance-attribute
model = Project
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

Project-scoped collections

project_context

The project-scoped endpoints, /projects/{project_id}/....

Call the projects resource with a project id (or a Project) to get a ProjectContext, the handle every nested route hangs off:

client.projects(project_id).sites.list()
client.projects(project_id).beltfish_methods.get(method_id)

Each collection behaves exactly like a top-level one: a lazy, filterable PaginatedList from .list(**filters) and a single record from .get(id). They differ only in their path, so each is a ProjectResource declaring its route and model.

The context also carries the aggregated views of datamermaid.resources.aggregated (project.beltfishes.observations() and its siblings), which are list-only and answer with flat rows rather than nested models.

Classes:

Name Description
ProjectResource

A read-only collection nested under one project.

ProjectSitesResource

The project's reef sites (sites/).

ProjectManagementsResource

The project's management regimes (managements/).

ProjectObserversResource

Who recorded the project's sample unit methods (observers/).

ProjectProfilesResource

The project's members and their roles (project_profiles/).

ProjectSampleEventsResource

Site-and-date visits the project's sample units belong to (sampleevents/).

ProjectFishBeltTransectsResource

The project's fish belt transects (fishbelttransects/).

ProjectBenthicTransectsResource

The project's benthic transects (benthictransects/).

ProjectBeltFishMethodsResource

Fish belt surveys with their observations (beltfishtransectmethods/).

ProjectBenthicLITMethodsResource

Benthic LIT surveys with their observations (benthiclittransectmethods/).

ProjectBenthicPITMethodsResource

Benthic PIT surveys with their observations (benthicpittransectmethods/).

ProjectBenthicPQTMethodsResource

Benthic photo quadrat surveys (benthicphotoquadrattransectmethods/).

ProjectHabitatComplexityMethodsResource

Habitat complexity surveys (habitatcomplexitytransectmethods/).

ProjectBleachingQCMethodsResource

Bleaching quadrat collection surveys (bleachingquadratcollectionmethods/).

ProjectBeltInvertMethodsResource

Macroinvertebrate belt surveys (beltinverttransectmethods/).

ProjectContext

One project's data, as the collections nested under it.

Functions:

Name Description
project_path

Compose projects/<project_id>/<route>.

Attributes:

Name Type Description
PROJECT_RESOURCES tuple[tuple[str, type[ProjectResource[Any]]], ...]

PROJECT_RESOURCES module-attribute

PROJECT_RESOURCES: tuple[
    tuple[str, type[ProjectResource[Any]]], ...
] = (
    ("sites", ProjectSitesResource),
    ("managements", ProjectManagementsResource),
    ("observers", ProjectObserversResource),
    ("project_profiles", ProjectProfilesResource),
    ("sample_events", ProjectSampleEventsResource),
    (
        "fishbelt_transects",
        ProjectFishBeltTransectsResource,
    ),
    ("benthic_transects", ProjectBenthicTransectsResource),
    ("beltfish_methods", ProjectBeltFishMethodsResource),
    (
        "benthiclit_methods",
        ProjectBenthicLITMethodsResource,
    ),
    (
        "benthicpit_methods",
        ProjectBenthicPITMethodsResource,
    ),
    (
        "benthicpqt_methods",
        ProjectBenthicPQTMethodsResource,
    ),
    (
        "habitatcomplexity_methods",
        ProjectHabitatComplexityMethodsResource,
    ),
    (
        "bleachingqc_methods",
        ProjectBleachingQCMethodsResource,
    ),
    (
        "beltinvert_methods",
        ProjectBeltInvertMethodsResource,
    ),
)

ProjectResource

ProjectResource(client: MermaidClient, project_id: str)

Bases: ReadOnlyResource[M]

A read-only collection nested under one project.

Subclasses declare route and model; the project id turns the route into a path when the resource is built.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route str
project_id
path
model type[M]
route instance-attribute
route: str
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
path instance-attribute
path = project_path(self.project_id, self.route)
model instance-attribute
model: type[M]
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectSitesResource

ProjectSitesResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[Site]

The project's reef sites (sites/).

Filters: name, country, reef_type, reef_zone, exposure.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'sites/'
model class-attribute instance-attribute
model = Site
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectManagementsResource

ProjectManagementsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[Management]

The project's management regimes (managements/).

Filters: name, est_year, parties, compliance and the seven rule flags (no_take, periodic_closure, ...).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'managements/'
model class-attribute instance-attribute
model = Management
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectObserversResource

ProjectObserversResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[Observer]

Who recorded the project's sample unit methods (observers/).

Filters: transectmethod, profile, rank.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'observers/'
model class-attribute instance-attribute
model = Observer
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectProfilesResource

ProjectProfilesResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[ProjectProfile]

The project's members and their roles (project_profiles/).

Filters: profile, role.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'project_profiles/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectSampleEventsResource

ProjectSampleEventsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[SampleEvent]

Site-and-date visits the project's sample units belong to (sampleevents/).

Filters: site, management and the sample_date range (sample_date_after / sample_date_before).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'sampleevents/'
model class-attribute instance-attribute
model = SampleEvent
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectFishBeltTransectsResource

ProjectFishBeltTransectsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[FishBeltTransect]

The project's fish belt transects (fishbelttransects/).

The transects alone, without the observations recorded on them; for those use ProjectBeltFishMethodsResource. Filters: sample_event, len_surveyed, width, depth.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'fishbelttransects/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectBenthicTransectsResource

ProjectBenthicTransectsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[BenthicTransect]

The project's benthic transects (benthictransects/).

Shared by the benthic LIT, benthic PIT and habitat complexity protocols. Filters: sample_event, len_surveyed, depth.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'benthictransects/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectBeltFishMethodsResource

ProjectBeltFishMethodsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[BeltFishMethod]

Fish belt surveys with their observations (beltfishtransectmethods/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'beltfishtransectmethods/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectBenthicLITMethodsResource

ProjectBenthicLITMethodsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[BenthicLITMethod]

Benthic LIT surveys with their observations (benthiclittransectmethods/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'benthiclittransectmethods/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectBenthicPITMethodsResource

ProjectBenthicPITMethodsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[BenthicPITMethod]

Benthic PIT surveys with their observations (benthicpittransectmethods/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'benthicpittransectmethods/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectBenthicPQTMethodsResource

ProjectBenthicPQTMethodsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[BenthicPhotoQuadratTransectMethod]

Benthic photo quadrat surveys (benthicphotoquadrattransectmethods/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'benthicphotoquadrattransectmethods/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectHabitatComplexityMethodsResource

ProjectHabitatComplexityMethodsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[HabitatComplexityMethod]

Habitat complexity surveys (habitatcomplexitytransectmethods/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'habitatcomplexitytransectmethods/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectBleachingQCMethodsResource

ProjectBleachingQCMethodsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[BleachingQuadratCollectionMethod]

Bleaching quadrat collection surveys (bleachingquadratcollectionmethods/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'bleachingquadratcollectionmethods/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectBeltInvertMethodsResource

ProjectBeltInvertMethodsResource(
    client: MermaidClient, project_id: str
)

Bases: ProjectResource[BeltInvertMethod]

Macroinvertebrate belt surveys (beltinverttransectmethods/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
route
model
path
project_id
route class-attribute instance-attribute
route = 'beltinverttransectmethods/'
model class-attribute instance-attribute
path instance-attribute
path = project_path(self.project_id, self.route)
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectContext

ProjectContext(
    client: MermaidClient, project: str | Project
)

One project's data, as the collections nested under it.

Built by calling the projects resource with an id or a Project. Nothing is requested when the context is built, and each collection below it is a lazy list like every other endpoint in the SDK.

Parameters:

Name Type Description Default
client MermaidClient

The client the nested requests are made through.

required
project str | Project

The project's id, or a Project.

required

Raises:

Type Description
ValueError

If the project id is empty.

Attributes:

Name Type Description
project_id

The id every route below this handle is built from.

Example
project = client.projects(project_id)

for site in project.sites.list():
    print(site.name)

# The seven protocols' aggregated views hang off the same handle.
project.beltfishes.observations().to_df()
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
sites cached property

The project's reef sites, /projects/{id}/sites/.

managements cached property

The project's management regimes, /projects/{id}/managements/.

observers cached property

Observers credited on the project's surveys, /projects/{id}/observers/.

project_profiles cached property
project_profiles: ProjectProfilesResource

The project's members, /projects/{id}/project_profiles/.

sample_events cached property

The project's sample events, /projects/{id}/sampleevents/.

fishbelt_transects cached property

Fish belt transects, /projects/{id}/fishbelttransects/.

benthic_transects cached property

Benthic transects, /projects/{id}/benthictransects/.

beltfish_methods cached property

Fish belt surveys, /projects/{id}/beltfishtransectmethods/.

benthiclit_methods cached property

Benthic LIT surveys, /projects/{id}/benthiclittransectmethods/.

benthicpit_methods cached property

Benthic PIT surveys, /projects/{id}/benthicpittransectmethods/.

benthicpqt_methods cached property

Benthic photo quadrat surveys, /projects/{id}/benthicphotoquadrattransectmethods/.

habitatcomplexity_methods cached property
habitatcomplexity_methods: (
    ProjectHabitatComplexityMethodsResource
)

Habitat complexity surveys, /projects/{id}/habitatcomplexitytransectmethods/.

bleachingqc_methods cached property
bleachingqc_methods: ProjectBleachingQCMethodsResource

Bleaching surveys, /projects/{id}/bleachingquadratcollectionmethods/.

beltinvert_methods cached property

Macroinvertebrate surveys, /projects/{id}/beltinverttransectmethods/.

beltfishes cached property

Aggregated fish belt data, /projects/{id}/beltfishes/.

benthiclits cached property

Aggregated benthic LIT data, /projects/{id}/benthiclits/.

benthicpits cached property

Aggregated benthic PIT data, /projects/{id}/benthicpits/.

benthicpqts cached property

Aggregated benthic photo quadrat data, /projects/{id}/benthicpqts/.

habitatcomplexities cached property
habitatcomplexities: AggregatedFamilyResource

Aggregated habitat complexity data, /projects/{id}/habitatcomplexities/.

bleachingqcs cached property

Aggregated bleaching data, /projects/{id}/bleachingqcs/.

Two observation views, colonies_bleached and quadrat_benthic_percent.

beltinverts cached property

Aggregated macroinvertebrate belt data, /projects/{id}/beltinverts/.

project_path

project_path(project_id: str, route: str) -> str

Compose projects/<project_id>/<route>.

The id is percent-encoded, so a stray / or .. in it cannot send the request to a different endpoint.

Aggregated observation views

aggregated

The aggregated observation views, /projects/{project_id}/<family>/....

Every protocol publishes its data three times over, denormalized: one row per observation, one per sample unit, and one per sample event, each already joined to its site, management regime and project. These are the routes analysts pull into a DataFrame:

project = client.projects(project_id)
project.beltfishes.observations(sample_date_after="2018-01-01").to_df()
project.benthicpits.sample_events().to_df()

The seven families differ only in their route and their columns, so each is an AggregatedViewFamily describing the former, and all of them share one AggregatedFamilyResource and one light AggregatedRecord, whose declared fields are the few every view has in common. Bleaching is the exception: it publishes two observation views, so it gets BleachingQCFamilyResource.

Sub-route names follow mermaid-api's src/api/urls.py (dev branch).

Classes:

Name Description
AggregatedViewFamily

One protocol's aggregated views, as route segments under a project.

AggregatedFamilyResource

One protocol's aggregated views for one project.

BleachingQCFamilyResource

The bleaching quadrat collections, which publish two observation views.

Attributes:

Name Type Description
BELTFISHES
BENTHICLITS
BENTHICPITS
BENTHICPQTS
HABITATCOMPLEXITIES
BLEACHINGQCS
BELTINVERTS
AGGREGATED_FAMILIES tuple[AggregatedViewFamily, ...]

BELTFISHES module-attribute

BELTFISHES = AggregatedViewFamily(
    "beltfishes", "obstransectbeltfishes"
)

BENTHICLITS module-attribute

BENTHICLITS = AggregatedViewFamily(
    "benthiclits", "obstransectbenthiclits"
)

BENTHICPITS module-attribute

BENTHICPITS = AggregatedViewFamily(
    "benthicpits", "obstransectbenthicpits"
)

BENTHICPQTS module-attribute

BENTHICPQTS = AggregatedViewFamily(
    "benthicpqts", "obstransectbenthicpqts"
)

HABITATCOMPLEXITIES module-attribute

HABITATCOMPLEXITIES = AggregatedViewFamily(
    "habitatcomplexities", "obshabitatcomplexities"
)

BLEACHINGQCS module-attribute

BLEACHINGQCS = AggregatedViewFamily(
    "bleachingqcs",
    "obscoloniesbleacheds",
    extra_observations=(
        (
            "quadrat_benthic_percent",
            "obsquadratbenthicpercents",
        ),
    ),
)

BELTINVERTS module-attribute

BELTINVERTS = AggregatedViewFamily(
    "beltinverts", "obstransectbeltinverts"
)

AGGREGATED_FAMILIES module-attribute

AggregatedViewFamily dataclass

AggregatedViewFamily(
    family: str,
    observations: str,
    extra_observations: tuple[tuple[str, str], ...] = (),
    sample_units: str = "sampleunits",
    sample_events: str = "sampleevents",
)

One protocol's aggregated views, as route segments under a project.

family is both the first segment of the route and the attribute the ProjectContext exposes it as, e.g. beltfishes for /projects/{id}/beltfishes/.

Methods:

Name Description
route

<family>/<sub_route>/, the route below the project.

Attributes:

Name Type Description
family str
observations str
extra_observations tuple[tuple[str, str], ...]
sample_units str
sample_events str
views dict[str, str]

Resource method name -> sub-route, for every view of the family.

family instance-attribute
family: str
observations instance-attribute
observations: str
extra_observations class-attribute instance-attribute
extra_observations: tuple[tuple[str, str], ...] = ()
sample_units class-attribute instance-attribute
sample_units: str = 'sampleunits'
sample_events class-attribute instance-attribute
sample_events: str = 'sampleevents'
views property
views: dict[str, str]

Resource method name -> sub-route, for every view of the family.

route
route(sub_route: str) -> str

<family>/<sub_route>/, the route below the project.

AggregatedFamilyResource

AggregatedFamilyResource(
    client: MermaidClient,
    project_id: str,
    family: AggregatedViewFamily,
)

Bases: Resource[AggregatedRecord]

One protocol's aggregated views for one project.

Each method returns the same lazy PaginatedList as every other list route, over AggregatedRecord rows. Keyword arguments become query parameters, so the API's own filters pass straight through: sample_date_before / sample_date_after, depth_min / depth_max, site_id, management_id, label, observers, the protocol's own filters, and the parameters every list route understands (limit, ordering, fields). An argument whose value is None is left out.

Methods:

Name Description
observations

One row per observation, with its sample unit and site joined in.

sample_units

One row per sample unit, with the protocol's per-unit aggregates.

sample_events

One row per sample event, averaged over the event's sample units.

Attributes:

Name Type Description
model
project_id
family
path
model class-attribute instance-attribute
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
family instance-attribute
family = family
path instance-attribute
path = project_path(self.project_id, f'{family.family}/')
observations
observations(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

One row per observation, with its sample unit and site joined in.

sample_units
sample_units(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

One row per sample unit, with the protocol's per-unit aggregates.

sample_events
sample_events(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

One row per sample event, averaged over the event's sample units.

BleachingQCFamilyResource

BleachingQCFamilyResource(
    client: MermaidClient,
    project_id: str,
    family: AggregatedViewFamily,
)

Bases: AggregatedFamilyResource

The bleaching quadrat collections, which publish two observation views.

colonies_bleached is the per-colony view and quadrat_benthic_percent the per-quadrat benthic cover view; observations is an alias of the former, so the family still answers the same three methods as its siblings.

Methods:

Name Description
colonies_bleached

One row per bleached colony count (obscoloniesbleacheds/).

quadrat_benthic_percent

One row per quadrat's benthic percent cover (obsquadratbenthicpercents/).

observations

The colonies bleached view; see

sample_units

One row per sample unit, with the protocol's per-unit aggregates.

sample_events

One row per sample event, averaged over the event's sample units.

Attributes:

Name Type Description
path
model
project_id
family
path instance-attribute
path = project_path(self.project_id, f'{family.family}/')
model class-attribute instance-attribute
project_id instance-attribute
project_id = _normalize_id(project_id, name='project id')
family instance-attribute
family = family
colonies_bleached
colonies_bleached(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

One row per bleached colony count (obscoloniesbleacheds/).

quadrat_benthic_percent
quadrat_benthic_percent(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

One row per quadrat's benthic percent cover (obsquadratbenthicpercents/).

observations
observations(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

The colonies bleached view; see colonies_bleached.

sample_units
sample_units(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

One row per sample unit, with the protocol's per-unit aggregates.

sample_events
sample_events(
    *,
    limit: int | None = None,
    offset: int | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    sample_date_after: str | None = None,
    sample_date_before: str | None = None,
    site_id: str | None = None,
    **filters: Any,
) -> PaginatedList[AggregatedRecord]

One row per sample event, averaged over the event's sample units.

Reference and lookup endpoints

reference

The top-level reference, lookup and summary endpoints.

Every endpoint here is a read-only, paginated list with a /<id>/ detail route, so each wrapper is just a path and a model on top of ReadOnlyResource. The filters named in each docstring are the ones the API declares; any other keyword argument is forwarded as a query parameter too, as are limit, search, ordering and fields.

Most of these are public. /sites/ and /managements/ are the exception: they hold project data and need credentials.

Classes:

Name Description
SitesResource

Reef sites across every project the credentials can see (/sites/).

ManagementsResource

Management regimes (/managements/).

ProjectTagsResource

Organisation tags projects can be labelled with (/projecttags/).

FishSizesResource

The bins of every fish size bin set (/fishsizes/).

FishFamiliesResource

Fish families (/fishfamilies/).

FishGeneraResource

Fish genera (/fishgenera/).

FishSpeciesResource

Fish species (/fishspecies/).

BenthicAttributesResource

Benthic attributes (/benthicattributes/).

InvertAttributesResource

Macroinvertebrate attributes at every rank (/invertattributes/).

InvertSpeciesResource

Macroinvertebrate species (/invertspecies/).

SummarySampleEventsResource

Public per-sample-event summaries (/summarysampleevents/).

LabelMappingsResource

Image classifier labels mapped onto MERMAID attributes.

Attributes:

Name Type Description
REFERENCE_RESOURCES tuple[tuple[str, type[ReadOnlyResource[Any]]], ...]

REFERENCE_RESOURCES module-attribute

REFERENCE_RESOURCES: tuple[
    tuple[str, type[ReadOnlyResource[Any]]], ...
] = (
    ("sites", SitesResource),
    ("managements", ManagementsResource),
    ("project_tags", ProjectTagsResource),
    ("fish_sizes", FishSizesResource),
    ("fish_families", FishFamiliesResource),
    ("fish_genera", FishGeneraResource),
    ("fish_species", FishSpeciesResource),
    ("benthic_attributes", BenthicAttributesResource),
    ("invert_attributes", InvertAttributesResource),
    ("invert_species", InvertSpeciesResource),
    ("summary_sample_events", SummarySampleEventsResource),
    ("label_mappings", LabelMappingsResource),
)

SitesResource

SitesResource(client: MermaidClient)

Bases: ReadOnlyResource[Site]

Reef sites across every project the credentials can see (/sites/).

Requires authentication. Filters: project, country, reef_type, reef_zone, exposure, exclude_projects, unique.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'sites/'
model class-attribute instance-attribute
model = Site
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ManagementsResource

ManagementsResource(client: MermaidClient)

Bases: ReadOnlyResource[Management]

Management regimes (/managements/).

Requires authentication. Filters: project, predecessor, parties, compliance, est_year, the seven rule flags (no_take, periodic_closure, open_access, size_limits, gear_restriction, species_restriction, access_restriction), unique and exclude_projects.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'managements/'
model class-attribute instance-attribute
model = Management
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

ProjectTagsResource

ProjectTagsResource(client: MermaidClient)

Bases: ReadOnlyResource[ProjectTag]

Organisation tags projects can be labelled with (/projecttags/).

Filters: name, status.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'projecttags/'
model class-attribute instance-attribute
model = ProjectTag
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

FishSizesResource

FishSizesResource(client: MermaidClient)

Bases: ReadOnlyResource[FishSize]

The bins of every fish size bin set (/fishsizes/).

Filters: val.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'fishsizes/'
model class-attribute instance-attribute
model = FishSize
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

FishFamiliesResource

FishFamiliesResource(client: MermaidClient)

Bases: ReadOnlyResource[FishFamily]

Fish families (/fishfamilies/).

Filters: status, regions (a comma-separated list of region ids).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'fishfamilies/'
model class-attribute instance-attribute
model = FishFamily
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

FishGeneraResource

FishGeneraResource(client: MermaidClient)

Bases: ReadOnlyResource[FishGenus]

Fish genera (/fishgenera/).

Filters: family, status, regions.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'fishgenera/'
model class-attribute instance-attribute
model = FishGenus
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

FishSpeciesResource

FishSpeciesResource(client: MermaidClient)

Bases: ReadOnlyResource[FishSpecies]

Fish species (/fishspecies/).

Filters: genus, genus__family, status, regions.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'fishspecies/'
model class-attribute instance-attribute
model = FishSpecies
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

BenthicAttributesResource

BenthicAttributesResource(client: MermaidClient)

Bases: ReadOnlyResource[BenthicAttribute]

Benthic attributes (/benthicattributes/).

Filters: parent (pass an empty string for the top-level attributes), life_history, region.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'benthicattributes/'
model class-attribute instance-attribute
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

InvertAttributesResource

InvertAttributesResource(client: MermaidClient)

Bases: ReadOnlyResource[InvertAttribute]

Macroinvertebrate attributes at every rank (/invertattributes/).

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'invertattributes/'
model class-attribute instance-attribute
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

InvertSpeciesResource

InvertSpeciesResource(client: MermaidClient)

Bases: ReadOnlyResource[InvertSpecies]

Macroinvertebrate species (/invertspecies/).

Filters: genus, genus__family, genus__group_of_interest, status.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'invertspecies/'
model class-attribute instance-attribute
model = InvertSpecies
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

SummarySampleEventsResource

SummarySampleEventsResource(client: MermaidClient)

Bases: ReadOnlyResource[SummarySampleEvent]

Public per-sample-event summaries (/summarysampleevents/).

Records are keyed by sample_event_id, which is also what get takes. Filters: project_id, project_name, project_admins, sample_date (as a range, sample_date_after / sample_date_before) and the seven data_policy_* fields.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'summarysampleevents/'
model class-attribute instance-attribute
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

LabelMappingsResource

LabelMappingsResource(client: MermaidClient)

Bases: ReadOnlyResource[LabelMapping]

Image classifier labels mapped onto MERMAID attributes.

/classification/labelmappings/. Filters: benthic_attribute, benthic_attribute__name, growth_form, growth_form__name, provider, provider_id, provider_label.

Methods:

Name Description
list

List records, lazily fetching pages as they are consumed.

get

Fetch a single record by id.

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'classification/labelmappings/'
model class-attribute instance-attribute
model = LabelMapping
list
list(
    *,
    limit: int | None = None,
    offset: int | None = None,
    search: str | None = None,
    ordering: str | None = None,
    fields: str | None = None,
    **filters: Any,
) -> PaginatedList[M]

List records, lazily fetching pages as they are consumed.

Keyword arguments become query parameters, so anything the endpoint filters on can be passed straight through, alongside the parameters every list route understands: limit, search, ordering and fields. An argument whose value is None is left out.

get
get(record_id: str, **params: Any) -> M

Fetch a single record by id.

Keyword arguments become query parameters, as for list.

Choices

choices

The /choices/ endpoint.

Unlike every other list route, /choices/ is not paginated: it answers with a bare JSON array of {"name": ..., "data": [...]} objects, one per choice set (countries, reeftypes, managementparties, ...). The detail route, /choices/<name>/, returns a single one of those objects. So this wrapper hands back plain dictionaries rather than models in a PaginatedList.

Classes:

Name Description
ChoicesResource

The controlled vocabularies the API validates submissions against.

ChoiceSet module-attribute

ChoiceSet = list[dict[str, Any]]

ChoicesResource

ChoicesResource(client: MermaidClient)

Bases: BaseResource

The controlled vocabularies the API validates submissions against.

Methods:

Name Description
fetch

Fetch every choice set, keyed by name (GET /choices/).

get

Fetch a single choice set by name (GET /choices/<name>/).

Attributes:

Name Type Description
path
path class-attribute instance-attribute
path = 'choices/'
fetch
fetch() -> dict[str, ChoiceSet]

Fetch every choice set, keyed by name (GET /choices/).

get
get(name: str) -> ChoiceSet

Fetch a single choice set by name (GET /choices/<name>/).

Profile

me

The /me/ endpoint.

Classes:

Name Description
MeResource

The profile owning the credentials in use.

MeResource

MeResource(client: MermaidClient)

Bases: Resource[Me]

The profile owning the credentials in use.

Methods:

Name Description
get

Fetch the authenticated profile (GET /me/).

Attributes:

Name Type Description
path
model
path class-attribute instance-attribute
path = 'me/'
model class-attribute instance-attribute
model = Me
get
get() -> Me

Fetch the authenticated profile (GET /me/).

Zonal statistics

zonal_stats

The Zonal Stats service, https://api.zonalstats.datamermaid.org/.

A separate FastAPI service, not a route of the MERMAID API: it lives on its own host, resolved independently of the client's base_url (see MermaidClient's zonal_stats_url), takes no authentication, and its routes have no trailing slash. Each endpoint takes a GeoJSON area of interest plus the URL of a data source and answers with statistics keyed by band or column:

result = client.zonal_stats.raster.stats(
    {"type": "Point", "coordinates": [178.4, -18.1]},
    url="https://example.test/depth.tif",
    stats=["mean", "count"],
    radius=500,
)
result["band_1"]["mean"]

There are four routes, one per kind of source, listed in ZONAL_STATS_ENDPOINTS:

Property Route Source Keys
raster raster a Cloud Optimized GeoTIFF band_1, ...
raster_stac raster/stac a STAC Item whose asset is a GeoTIFF band_1, ...
vector vector a GeoParquet file column names
vector_stac vector/stac a STAC Item whose asset is GeoParquet column names
result = client.zonal_stats.raster_stac.stats(
    aoi, url="https://example.test/item.json", asset="visual", bands=[1, 2]
)
result = client.zonal_stats.vector.stats(
    aoi, url="https://example.test/habitat.parquet", columns=["depth"], weighting_method="ratio"
)
result["depth"]["mean"]

The statistic names and the vector weighting methods are fixed vocabularies, Stat and WeightingMethod. Plain strings are accepted too; an unknown one raises ValueError before any request is made.

The area of interest goes through to_aoi, so a Site, a shapely geometry or a (lon, lat) tuple work just as well as a GeoJSON mapping:

site = client.projects(project_id).sites.get(site_id)
result = client.zonal_stats.raster.stats(site, url="https://example.test/depth.tif", radius=500)

Many areas of interest go through batch, which returns a completed Batch that issues one request per AOI on a bounded thread pool and labels each result so to_df() gives one row per AOI:

batch = client.zonal_stats.raster.batch(sites, url="https://example.test/depth.tif")
frame = batch.to_df()  # one wide row per site, keyed by `label` (the site id)

Because the requests go to another host, they are sent without the client's auth and without the headers passed to it with headers=, so the MERMAID credentials the client holds are never disclosed to it. Retries, backoff and error mapping are the client's own.

Classes:

Name Description
Stat

A statistic the service can compute: the StatType vocabulary.

WeightingMethod

How the vector routes weight each feature that intersects the AOI.

BatchItem

Legacy input tuple; current zonal batches expose ZonalTask inputs.

ResponseCache

A thread-safe, size-bounded, in-memory cache of zonal stats responses.

BaseZonalStats

One route of the Zonal Stats service.

RasterStats

POST .../zonal-stats/raster: statistics from a Cloud Optimized GeoTIFF.

RasterStacStats

POST .../zonal-stats/raster/stac: statistics from a raster asset of a STAC Item.

VectorStats

POST .../zonal-stats/vector: area-weighted statistics from a GeoParquet file.

VectorStacStats

POST .../zonal-stats/vector/stac: statistics from a GeoParquet asset of a STAC Item.

ZonalStats

The Zonal Stats service, as client.zonal_stats.

Attributes:

Name Type Description
ZONAL_STATS_ENDPOINTS tuple[tuple[str, type[BaseZonalStats]], ...]

ZONAL_STATS_ENDPOINTS module-attribute

ZONAL_STATS_ENDPOINTS: tuple[
    tuple[str, type[BaseZonalStats]], ...
] = (
    ("raster", RasterStats),
    ("raster_stac", RasterStacStats),
    ("vector", VectorStats),
    ("vector_stac", VectorStacStats),
)

Stat

Bases: str, Enum

A statistic the service can compute: the StatType vocabulary.

Members compare equal to their wire value, so Stat.MEAN == "mean", and stats= takes members and plain strings alike.

Attributes:

Name Type Description
MIN
MAX
MEAN
COUNT
SUM
STD
MEDIAN
MAJORITY
MINORITY
UNIQUE
RANGE
NODATA
AOI_AREA
DATA_AREA
FREQ_HIST
DENSITY
MIN class-attribute instance-attribute
MIN = 'min'
MAX class-attribute instance-attribute
MAX = 'max'
MEAN class-attribute instance-attribute
MEAN = 'mean'
COUNT class-attribute instance-attribute
COUNT = 'count'
SUM class-attribute instance-attribute
SUM = 'sum'
STD class-attribute instance-attribute
STD = 'std'
MEDIAN class-attribute instance-attribute
MEDIAN = 'median'
MAJORITY class-attribute instance-attribute
MAJORITY = 'majority'
MINORITY class-attribute instance-attribute
MINORITY = 'minority'
UNIQUE class-attribute instance-attribute
UNIQUE = 'unique'
RANGE class-attribute instance-attribute
RANGE = 'range'
NODATA class-attribute instance-attribute
NODATA = 'nodata'
AOI_AREA class-attribute instance-attribute
AOI_AREA = 'aoi_area'
DATA_AREA class-attribute instance-attribute
DATA_AREA = 'data_area'
FREQ_HIST class-attribute instance-attribute
FREQ_HIST = 'freq_hist'
DENSITY class-attribute instance-attribute
DENSITY = 'density'

WeightingMethod

Bases: str, Enum

How the vector routes weight each feature that intersects the AOI.

Attributes:

Name Type Description
AREA
RATIO
AREA class-attribute instance-attribute
AREA = 'area'
RATIO class-attribute instance-attribute
RATIO = 'ratio'

BatchItem

Bases: NamedTuple

Legacy input tuple; current zonal batches expose ZonalTask inputs.

Attributes:

Name Type Description
aoi Any
label Any
aoi instance-attribute
aoi: Any
label instance-attribute
label: Any

ResponseCache

ResponseCache(maxsize: int = 10000)

Bases: MutableMapping[str, Any]

A thread-safe, size-bounded, in-memory cache of zonal stats responses.

Each ZonalStats resource holds one as client.zonal_stats.cache, and batch uses it unless told otherwise. When full, the least recently used entry is dropped.

Methods:

Name Description
clear

Attributes:

Name Type Description
maxsize
maxsize instance-attribute
maxsize = maxsize
clear
clear() -> None

BaseZonalStats

BaseZonalStats(resource: ZonalStats)

One route of the Zonal Stats service.

Subclasses set route (the segment after .../zonal-stats/) and extend stats with the options that route accepts. Calling the endpoint is the same as calling stats.

Methods:

Name Description
prepare

Resolve sources and count pairs without submitting statistics requests.

stats

Compute statistics for aoi against the source at url.

batch

One statistics request per area of interest, run on a bounded thread pool.

Attributes:

Name Type Description
route str
url str

The absolute URL POSTed to. No trailing slash: the service has none.

route class-attribute
route: str
url property
url: str

The absolute URL POSTed to. No trailing slash: the service has none.

prepare
prepare(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> ZonalJob

Resolve sources and count pairs without submitting statistics requests.

Supply exactly one of url, sources (URLs or STAC Items), or a pystac-client ItemSearch via search. Item assets resolve to data URLs; string URLs retain this endpoint's usual meaning. AOIs and sources are retained, but their Cartesian product is generated lazily at execution.

stats
stats(
    aoi: GeometryLike,
    *,
    url: str,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    label: Any = None,
    **options: Any,
) -> ZonalStatsResult

Compute statistics for aoi against the source at url.

Parameters:

Name Type Description Default
aoi GeometryLike

Anything to_aoi accepts: a GeoJSON Point or Polygon mapping, a Feature holding one, an object with a __geo_interface__, a (lon, lat) tuple, or a Site.

required
url str

The data source the route reads, e.g. a Cloud Optimized GeoTIFF.

required
stats Iterable[Stat | str] | None

Stat members or their names (mean, count, median, ...). When omitted the service picks its defaults.

None
radius float | None

Buffer around a Point, in metres.

None
label Any

An identifier carried onto the result unchanged.

None
**options Any

Route-specific body fields; a None value is left out.

{}

Raises:

Type Description
TypeError

If aoi is none of the kinds to_aoi accepts.

ValueError

If aoi is not a Point or Polygon, a statistic name is unknown, or an option is malformed.

MermaidAPIError

If the service rejects the request (422 for a validation error, 400 for an unreadable source).

batch
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> Batch[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> BatchStream[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> (
    Batch[ZonalTask, ZonalStatsResult]
    | BatchStream[ZonalTask, ZonalStatsResult]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> Batch[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> BatchStream[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)

One statistics request per area of interest, run on a bounded thread pool.

By default this call waits for all requests and returns a completed Batch in input order. aois is read in full, so a lazy list such as sites.list() fetches all its pages. Each result carries a label, so batch.to_df() is one row per AOI.

Parameters:

Name Type Description Default
aois Any

An iterable of areas of interest (anything stats accepts), or one object whose __geo_interface__ is a FeatureCollection, such as a GeoDataFrame, which expands into its features.

required
url str | None

The data source the route reads; exclusive with sources/search.

None
sources Iterable[SourceInput] | None

Iterable of source URLs or STAC Items.

None
search StacSearchLike | None

A pystac-client ItemSearch, resolved once before execution.

None
stream bool

Return a single-pass BatchStream instead of retaining results. Use as a context manager and keep the client open while iterating.

False
labels Iterable[Any] | None

One label per AOI, in order. Omitted, a Site is labelled by its id, a Feature by its id, and anything else by its position.

None
max_workers int

Most requests in flight at once.

DEFAULT_MAX_WORKERS
cache MutableMapping[str, Any] | bool | None

Where successful responses are kept, keyed by a hash of the route and the request body. A request already in the cache is answered without calling the service, so a rerun only sends the requests that failed or are new. True (the default) uses client.zonal_stats.cache, an in-memory ResponseCache shared by every batch on the client. False or None sends every request and stores nothing. Any other mutable mapping, such as a dict or a diskcache.Cache, is used in its place. Failures are never stored. The key does not cover the source's contents, so clear the cache if the data at a URL changes. Two workers asking for the same uncached body at once both send it.

True
errors Literal['raise', 'return']

"raise" raises the first error in input order after all requests finish; "return" retains BatchFailure objects with the input task and original exception.

'raise'
stats Iterable[Stat | str] | None

Statistic names, as for stats.

None
radius float | None

Buffer around a Point, in metres.

None
**options Any

Route-specific body fields; a None value is left out.

{}

Raises:

Type Description
ValueError

If url is empty, labels has the wrong length, or max_workers is below 1.

TypeError

If aois is not iterable, or is a single geometry, or cache is not a bool, None or a mutable mapping.

RasterStats

RasterStats(resource: ZonalStats)

Bases: BaseZonalStats

POST .../zonal-stats/raster: statistics from a Cloud Optimized GeoTIFF.

Methods:

Name Description
prepare

Prepare source calculations using the same options as stats() and batch().

stats

Compute statistics for aoi over the raster at url.

batch

One raster statistics request per area of interest, run in parallel.

Attributes:

Name Type Description
route
url str

The absolute URL POSTed to. No trailing slash: the service has none.

route class-attribute instance-attribute
route = 'raster'
url property
url: str

The absolute URL POSTed to. No trailing slash: the service has none.

prepare
prepare(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> ZonalJob

Prepare source calculations using the same options as stats() and batch().

stats
stats(
    aoi: GeometryLike,
    *,
    url: str,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
    label: Any = None,
) -> ZonalStatsResult

Compute statistics for aoi over the raster at url.

Parameters:

Name Type Description Default
aoi GeometryLike

Anything to_aoi accepts: a GeoJSON Point or Polygon mapping, a Feature, an object with a __geo_interface__, a (lon, lat) tuple, or a Site.

required
url str

URL of the Cloud Optimized GeoTIFF (https:// or s3://).

required
stats Iterable[Stat | str] | None

Statistic names. Omitted, the service returns min, max, mean and count; aoi_area and data_area are always included.

None
radius float | None

Buffer around a Point, in metres.

None
bands Sequence[int] | None

1-based band indices to read. Omitted, the service reads band 1.

None
approx_stats bool

Read overviews for faster, approximate values.

False
label Any

An identifier carried onto the result unchanged.

None

Returns:

Type Description
ZonalStatsResult

The statistics keyed by band, band_1 for the first band.

batch
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> Batch[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> BatchStream[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> (
    Batch[ZonalTask, ZonalStatsResult]
    | BatchStream[ZonalTask, ZonalStatsResult]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> Batch[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> BatchStream[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)

One raster statistics request per area of interest, run in parallel.

Takes the same options as stats; see BaseZonalStats.batch for how aois, labels, max_workers and errors behave. The options are validated before any request is made.

Example
sites = client.projects(project_id).sites.list()
batch = client.zonal_stats.raster.batch(
    sites, url="https://example.test/depth.tif", stats=["mean"], radius=500
)
frame = batch.to_df()  # columns: label (the site id), source, band_1_mean

RasterStacStats

RasterStacStats(resource: ZonalStats)

Bases: RasterStats

POST .../zonal-stats/raster/stac: statistics from a raster asset of a STAC Item.

Methods:

Name Description
prepare

Prepare source calculations using the same options as stats() and batch().

stats

Compute statistics for aoi over a raster asset of the STAC Item at url.

batch

One STAC raster statistics request per area of interest, run in parallel.

Attributes:

Name Type Description
route
url str

The absolute URL POSTed to. No trailing slash: the service has none.

route class-attribute instance-attribute
route = 'raster/stac'
url property
url: str

The absolute URL POSTed to. No trailing slash: the service has none.

prepare
prepare(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> ZonalJob

Prepare source calculations using the same options as stats() and batch().

stats
stats(
    aoi: GeometryLike,
    *,
    url: str,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
    label: Any = None,
) -> ZonalStatsResult

Compute statistics for aoi over a raster asset of the STAC Item at url.

Parameters:

Name Type Description Default
aoi GeometryLike

Anything to_aoi accepts.

required
url str

URL of the STAC Item JSON.

required
stats Iterable[Stat | str] | None

Stat members or their names. Omitted, the service picks its defaults.

None
radius float | None

Buffer around a Point, in metres.

None
asset str | None

Key of the asset to read. Omitted, the service reads the Item's first asset.

None
bands Sequence[int] | None

1-based band indices to read. Omitted, the service reads band 1.

None
approx_stats bool

Read overviews for faster, approximate values.

False
label Any

An identifier carried onto the result unchanged.

None

Returns:

Type Description
ZonalStatsResult

The statistics keyed by band, band_1 for the first band.

batch
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> Batch[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> BatchStream[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> (
    Batch[ZonalTask, ZonalStatsResult]
    | BatchStream[ZonalTask, ZonalStatsResult]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> Batch[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> BatchStream[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    bands: Sequence[int] | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)

One STAC raster statistics request per area of interest, run in parallel.

Takes the same options as stats; see BaseZonalStats.batch for how aois, labels, max_workers and errors behave. The options are validated before any request is made.

VectorStats

VectorStats(resource: ZonalStats)

Bases: BaseZonalStats

POST .../zonal-stats/vector: area-weighted statistics from a GeoParquet file.

columns names the numeric columns to summarise and is required; the result is keyed by those names.

Methods:

Name Description
prepare

Prepare source calculations using the same options as stats() and batch().

stats

Compute statistics for aoi over the GeoParquet file at url.

batch

One vector statistics request per area of interest, run in parallel.

Attributes:

Name Type Description
route
url str

The absolute URL POSTed to. No trailing slash: the service has none.

route class-attribute instance-attribute
route = 'vector'
url property
url: str

The absolute URL POSTed to. No trailing slash: the service has none.

prepare
prepare(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> ZonalJob

Prepare source calculations using the same options as stats() and batch().

stats
stats(
    aoi: GeometryLike,
    *,
    url: str,
    columns: Sequence[str],
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
    label: Any = None,
) -> ZonalStatsResult

Compute statistics for aoi over the GeoParquet file at url.

Parameters:

Name Type Description Default
aoi GeometryLike

Anything to_aoi accepts.

required
url str

URL of the GeoParquet file.

required
columns Sequence[str]

Numeric columns to summarise. Required and non-empty.

required
stats Iterable[Stat | str] | None

Stat members or their names. Omitted, the service picks its defaults.

None
radius float | None

Buffer around a Point, in metres.

None
geometry_column str | None

Name of the geometry column. Omitted, the service finds it from the file's metadata.

None
weighting_method WeightingMethod | str | None

How intersecting features are weighted, a WeightingMethod or its name. Omitted, the service weights by area.

None
approx_stats bool

Reserved by the service for a future optimisation.

False
label Any

An identifier carried onto the result unchanged.

None

Returns:

Type Description
ZonalStatsResult

The statistics keyed by column name.

Raises:

Type Description
ValueError

If columns is empty, or a statistic or weighting method name is unknown.

TypeError

If columns is a bare string or holds non-strings.

batch
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> Batch[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> BatchStream[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> (
    Batch[ZonalTask, ZonalStatsResult]
    | BatchStream[ZonalTask, ZonalStatsResult]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> Batch[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> BatchStream[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)

One vector statistics request per area of interest, run in parallel.

Takes the same options as stats; see BaseZonalStats.batch for how aois, labels, max_workers and errors behave. The options are validated before any request is made.

VectorStacStats

VectorStacStats(resource: ZonalStats)

Bases: VectorStats

POST .../zonal-stats/vector/stac: statistics from a GeoParquet asset of a STAC Item.

The vector route's options plus asset, the key of the GeoParquet asset to read.

Methods:

Name Description
prepare

Prepare source calculations using the same options as stats() and batch().

stats

Compute statistics for aoi over a GeoParquet asset of the STAC Item at url.

batch

One STAC vector statistics request per area of interest, run in parallel.

Attributes:

Name Type Description
route
url str

The absolute URL POSTed to. No trailing slash: the service has none.

route class-attribute instance-attribute
route = 'vector/stac'
url property
url: str

The absolute URL POSTed to. No trailing slash: the service has none.

prepare
prepare(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> ZonalJob

Prepare source calculations using the same options as stats() and batch().

stats
stats(
    aoi: GeometryLike,
    *,
    url: str,
    columns: Sequence[str],
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
    label: Any = None,
) -> ZonalStatsResult

Compute statistics for aoi over a GeoParquet asset of the STAC Item at url.

Parameters:

Name Type Description Default
aoi GeometryLike

Anything to_aoi accepts.

required
url str

URL of the STAC Item JSON.

required
columns Sequence[str]

Numeric columns to summarise. Required and non-empty.

required
stats Iterable[Stat | str] | None

Stat members or their names. Omitted, the service picks its defaults.

None
radius float | None

Buffer around a Point, in metres.

None
asset str | None

Key of the GeoParquet asset to read. Omitted, the service reads the Item's first asset.

None
geometry_column str | None

Name of the geometry column. Omitted, the service uses geometry.

None
weighting_method WeightingMethod | str | None

How intersecting features are weighted, a WeightingMethod or its name. Omitted, the service weights by area.

None
approx_stats bool

Reserved by the service for a future optimisation.

False
label Any

An identifier carried onto the result unchanged.

None

Returns:

Type Description
ZonalStatsResult

The statistics keyed by column name.

batch
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> Batch[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> BatchStream[ZonalTask, ZonalStatsResult]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> (
    Batch[ZonalTask, ZonalStatsResult]
    | BatchStream[ZonalTask, ZonalStatsResult]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[False] = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> Batch[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: Literal[True],
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> BatchStream[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)
batch(
    aois: Any,
    *,
    url: str | None = None,
    sources: Iterable[SourceInput] | None = None,
    search: StacSearchLike | None = None,
    stream: bool = False,
    columns: Sequence[str],
    labels: Iterable[Any] | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    asset: str | None = None,
    geometry_column: str | None = None,
    weighting_method: WeightingMethod | str | None = None,
    approx_stats: bool = False,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)

One STAC vector statistics request per area of interest, run in parallel.

Takes the same options as stats; see BaseZonalStats.batch for how aois, labels, max_workers and errors behave. The options are validated before any request is made.

ZonalStats

ZonalStats(client: MermaidClient)

Bases: BaseResource

The Zonal Stats service, as client.zonal_stats.

path is the absolute service root, so the endpoints bypass the client's base_url altogether.

Attributes:

Name Type Description
path
cache MutableMapping[str, Any]
raster RasterStats

Statistics from a Cloud Optimized GeoTIFF, POST .../raster.

raster_stac RasterStacStats

Statistics from a raster asset of a STAC Item, POST .../raster/stac.

vector VectorStats

Statistics from a GeoParquet file, POST .../vector.

vector_stac VectorStacStats

Statistics from a GeoParquet asset of a STAC Item, POST .../vector/stac.

path instance-attribute
path = client.zonal_stats_url
cache instance-attribute
cache: MutableMapping[str, Any] = ResponseCache()
raster cached property
raster: RasterStats

Statistics from a Cloud Optimized GeoTIFF, POST .../raster.

raster_stac cached property
raster_stac: RasterStacStats

Statistics from a raster asset of a STAC Item, POST .../raster/stac.

vector cached property
vector: VectorStats

Statistics from a GeoParquet file, POST .../vector.

vector_stac cached property
vector_stac: VectorStacStats

Statistics from a GeoParquet asset of a STAC Item, POST .../vector/stac.

Covariates

covariates

The MERMAID covariates catalog, a STAC API at https://mermaid.prescient.earth/stac/.

Covariates are the environmental and human-pressure datasets that sit next to MERMAID survey data: daily sea surface temperature and heat stress, reef habitat maps, market gravity, coastal population and more. Each dataset is a STAC collection, and each collection holds one or more items whose data asset is a Cloud Optimized GeoTIFF or a GeoParquet file.

The catalog is read with pystac-client, installed by the covariates extra (pip install 'datamermaid[covariates]'). Collections wrap a pystac.Collection and searches are plain pystac-client ItemSearch objects, so everything pystac offers is still there. The catalog is a public host, resolved independently of the client's base_url (see MermaidClient's covariates_url), and pystac-client never sees the client's MERMAID credentials.

See what is available:

for collection in client.covariates.collections():
    print(collection.id, collection.title)

client.covariates.search_collections("temperature")  # matches id or title
sst = client.covariates.collection("daily_sst")
print(sst.describe())

Compute statistics for many sites without choosing a route, an asset or a geometry column yourself:

batch = sst.zonal_stats(sites, datetime="2026-05", stats=["mean"], radius=500)
frame = batch.to_df()

Values are never rescaled here. A band's scale, offset and nodata are shown as metadata; the service reading the raster applies them.

Classes:

Name Description
CovariateCollection

One covariate dataset: a pystac.Collection and what it holds.

Covariates

The covariates catalog, as client.covariates.

PYSTAC_INSTALL_HINT module-attribute

PYSTAC_INSTALL_HINT = "client.covariates needs pystac-client; install it with `pip install 'datamermaid[covariates]'`"

Kind module-attribute

Kind = Literal['raster', 'vector']

CovariateCollection

CovariateCollection(
    resource: Covariates, collection: Collection
)

One covariate dataset: a pystac.Collection and what it holds.

Attributes of the underlying stac collection (title, description, keywords, license, providers, extent, summaries, ...) read straight through. The details of its data file (band units and scaling, class labels, GeoParquet columns) are only on its items, so sample_item fetches one item the first time any of them is asked for.

Methods:

Name Description
to_dict

One summary row: id, title, kind, time range, keywords and licence.

describe

A readable summary of the dataset, its data file and its provenance.

search

A pystac-client ItemSearch over this collection's items.

prepare_zonal_stats

Resolve the matching items and return a ZonalJob to run.

zonal_stats

Statistics for every AOI against every matching item of this dataset.

Attributes:

Name Type Description
stac
id str

The collection id, e.g. "daily_sst".

temporal_extent tuple[datetime | None, datetime | None]

The first and last moments covered, None for an open end.

citation str | None

The cite-as link, else a DOI URL from sci:doi.

kind Kind | None

"raster" or "vector": which zonal stats route reads this dataset.

sample_item Item | None

The collection's first item, fetched once, or None if it has none.

data_asset Asset | None

The sample item's asset with the data role.

bands list[dict[str, Any]]

raster:bands of the data asset: unit, scale, offset, nodata per band.

classes dict[Any, str]

Class value to label, for a categorical raster such as habitat or land cover.

columns list[dict[str, Any]]

table:columns of a GeoParquet data asset: name, type, description.

stac instance-attribute
stac = collection
id property
id: str

The collection id, e.g. "daily_sst".

temporal_extent property
temporal_extent: tuple[datetime | None, datetime | None]

The first and last moments covered, None for an open end.

citation property
citation: str | None

The cite-as link, else a DOI URL from sci:doi.

kind property
kind: Kind | None

"raster" or "vector": which zonal stats route reads this dataset.

Read from the collection's asset descriptions when it has them, so listing kinds needs no extra request; otherwise from data_asset.

sample_item cached property
sample_item: Item | None

The collection's first item, fetched once, or None if it has none.

data_asset property
data_asset: Asset | None

The sample item's asset with the data role.

bands property
bands: list[dict[str, Any]]

raster:bands of the data asset: unit, scale, offset, nodata per band.

classes property
classes: dict[Any, str]

Class value to label, for a categorical raster such as habitat or land cover.

columns property
columns: list[dict[str, Any]]

table:columns of a GeoParquet data asset: name, type, description.

to_dict
to_dict() -> dict[str, Any]

One summary row: id, title, kind, time range, keywords and licence.

Built from the collection document alone, so a table of every dataset costs one request.

describe
describe() -> str

A readable summary of the dataset, its data file and its provenance.

Fetches one item (see sample_item) and counts the items.

search
search(**parameters: Any) -> ItemSearch

A pystac-client ItemSearch over this collection's items.

Takes the keyword arguments of Covariates.search.

prepare_zonal_stats
prepare_zonal_stats(
    aois: Any,
    *,
    datetime: DatetimeLike | None = None,
    bbox: Sequence[float] | None = None,
    ids: Sequence[str] | None = None,
    max_items: int | None = None,
    asset: str | None = None,
    columns: Sequence[str] | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    **options: Any,
) -> ZonalJob

Resolve the matching items and return a ZonalJob to run.

Takes the same arguments as zonal_stats and sends no statistics requests, so job.request_count can be checked first.

zonal_stats
zonal_stats(
    aois: Any,
    *,
    datetime: DatetimeLike | None = None,
    bbox: Sequence[float] | None = None,
    ids: Sequence[str] | None = None,
    max_items: int | None = None,
    asset: str | None = None,
    columns: Sequence[str] | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stream: Literal[False] = False,
    **options: Any,
) -> Batch[ZonalTask, ZonalStatsResult]
zonal_stats(
    aois: Any,
    *,
    datetime: DatetimeLike | None = None,
    bbox: Sequence[float] | None = None,
    ids: Sequence[str] | None = None,
    max_items: int | None = None,
    asset: str | None = None,
    columns: Sequence[str] | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise"] = "raise",
    stream: Literal[True],
    **options: Any,
) -> BatchStream[ZonalTask, ZonalStatsResult]
zonal_stats(
    aois: Any,
    *,
    datetime: DatetimeLike | None = None,
    bbox: Sequence[float] | None = None,
    ids: Sequence[str] | None = None,
    max_items: int | None = None,
    asset: str | None = None,
    columns: Sequence[str] | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stream: Literal[False] = False,
    **options: Any,
) -> Batch[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
zonal_stats(
    aois: Any,
    *,
    datetime: DatetimeLike | None = None,
    bbox: Sequence[float] | None = None,
    ids: Sequence[str] | None = None,
    max_items: int | None = None,
    asset: str | None = None,
    columns: Sequence[str] | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stream: Literal[True],
    **options: Any,
) -> BatchStream[
    ZonalTask, ZonalStatsResult | BatchFailure[ZonalTask]
]
zonal_stats(
    aois: Any,
    *,
    datetime: DatetimeLike | None = None,
    bbox: Sequence[float] | None = None,
    ids: Sequence[str] | None = None,
    max_items: int | None = None,
    asset: str | None = None,
    columns: Sequence[str] | None = None,
    labels: Iterable[Any] | None = None,
    stats: Iterable[Stat | str] | None = None,
    radius: float | None = None,
    max_workers: int = DEFAULT_MAX_WORKERS,
    cache: MutableMapping[str, Any] | bool | None = True,
    errors: Literal["raise", "return"] = "raise",
    stream: bool = False,
    **options: Any,
) -> (
    Batch[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
    | BatchStream[
        ZonalTask,
        ZonalStatsResult | BatchFailure[ZonalTask],
    ]
)

Statistics for every AOI against every matching item of this dataset.

Chooses the route from the data asset's type (raster for a GeoTIFF, vector for GeoParquet), picks the asset with the data role, and for GeoParquet fills geometry_column and, when columns is left out, every numeric column from the item's table:columns. Each result carries the item's id and datetime in result.stac.

Parameters:

Name Type Description Default
aois Any

One area of interest or many, as the zonal stats batch methods take them: sites, GeoJSON, a GeoDataFrame.

required
datetime DatetimeLike | None

Which items to use, in any form pystac-client accepts: "2026-05", "2026-05-01/2026-05-15", a datetime or a (start, end) pair. Leave it out for a dataset with one item.

None
bbox Sequence[float] | None

Only items intersecting (west, south, east, north).

None
ids Sequence[str] | None

Only these item ids.

None
max_items int | None

Read at most this many items.

None
asset str | None

The asset key, when the data role is not the one wanted.

None
columns Sequence[str] | None

GeoParquet columns to summarise. Vector datasets only.

None
labels Iterable[Any] | None

One identifier per AOI; defaults as for BaseZonalStats.batch.

None
stats Iterable[Stat | str] | None

Statistic names; the service picks defaults when omitted.

None
radius float | None

Buffer around each Point, in metres.

None
max_workers int

Maximum concurrent requests.

DEFAULT_MAX_WORKERS
cache MutableMapping[str, Any] | bool | None

Response cache, as for the zonal stats batch methods.

True
errors Literal['raise', 'return']

"return" keeps failures as BatchFailure results.

'raise'
stream bool

True returns a BatchStream with bounded memory.

False
**options Any

Other route options, e.g. bands and approx_stats for rasters or weighting_method for vectors.

{}

Raises:

Type Description
ValueError

If no item matches, the asset is neither GeoTIFF nor GeoParquet, or a vector dataset has no numeric column to default to.

Covariates

Covariates(client: MermaidClient)

Bases: BaseResource

The covariates catalog, as client.covariates.

path is the absolute STAC API root, and catalog is the pystac-client Client opened on it. The list of collections is fetched once per client and kept; pass refresh=True to fetch it again.

Methods:

Name Description
collections

Every dataset in the catalog, in the catalog's order.

collection

One dataset by its exact id, e.g. "daily_sst".

search_collections

Datasets whose id or title contains query, ignoring case.

to_df

A table of datasets, one row per collection (optionally filtered by query).

search

A pystac-client ItemSearch, usable as search= on any zonal stats endpoint.

Attributes:

Name Type Description
path
catalog Client

The pystac-client Client for the catalog, opened on first use.

path instance-attribute
path = client.covariates_url
catalog cached property
catalog: Client

The pystac-client Client for the catalog, opened on first use.

collections
collections(
    *, refresh: bool = False
) -> list[CovariateCollection]

Every dataset in the catalog, in the catalog's order.

collection
collection(collection_id: str) -> CovariateCollection

One dataset by its exact id, e.g. "daily_sst".

Raises:

Type Description
APIError

If the catalog has no such collection.

search_collections
search_collections(query: str) -> list[CovariateCollection]

Datasets whose id or title contains query, ignoring case.

search_collections("sst") finds daily_sst, and search_collections("bleaching") finds the heat stress products by title.

to_df
to_df(query: str | None = None, **kwargs: Any) -> DataFrame

A table of datasets, one row per collection (optionally filtered by query).

search
search(
    collections: str
    | CovariateCollection
    | Sequence[str | CovariateCollection]
    | None = None,
    **parameters: Any,
) -> ItemSearch

A pystac-client ItemSearch, usable as search= on any zonal stats endpoint.

Parameters:

Name Type Description Default
collections str | CovariateCollection | Sequence[str | CovariateCollection] | None

A collection id or CovariateCollection, or several.

None
**parameters Any

The other keyword arguments of pystac_client.Client.search: datetime, bbox, ids, filter, sortby, max_items, limit, ... intersects also takes a Site or any __geo_interface__ object. None values are left out.

{}