Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

API reference

Everything below is importable from the top-level rle.core namespace unless noted otherwise:

from rle.core import Ecosystems, make_aoo_grid, make_eoo

The module version is available as rle.core.__version__.


Data model

Ecosystems

Abstract base class for ecosystem distribution datasets. Data is loaded lazily and cached on first access.

Constructor arguments (shared by concrete subclasses): data (path, URI, or GeoDataFrame), and keyword-only ecosystem_column, ecosystem_name_column, functional_group_column.

Factory classmethods:

Inspection and subsetting:

Derived metrics (single ecosystem; cached):

Export:

Visualization (require the viz extra):

EcosystemKind

Enum of backend kinds: VECTOR_LOCAL, RASTER_LOCAL, EE_FEATURE_COLLECTION, EE_IMAGE.

Concrete Ecosystems backends


Extent of Occurrence (EOO)

make_eoo(data, **kwargs)

Create an EOO from an Ecosystems instance. Local vector data returns an EOOVectorLocal; Earth Engine kinds require rle-python-gee. Call .compute() before reading results.

EOO

Abstract base class for Extent of Occurrence computations.

EOOVectorLocal

EOO from a local vector dataset (GeoDataFrame, GeoJSON, GeoParquet).

EOONotComputedError

Raised when accessing EOO results before compute().


Area of Occupancy (AOO)

make_aoo_grid(data, **kwargs)

Create an AOOGrid from an Ecosystems instance. VECTOR_LOCALAOOGridVectorLocal; RASTER_LOCALAOOGridCOG; Earth Engine kinds require rle-python-gee. Call .compute() before reading results.

make_aoo_grid_cached(data, *, cache_path, **kwargs)

An AOOGrid backed by a GeoParquet cache at cache_path (local or gs://). On a cache hit, loads the parquet and skips compute(); on a miss, computes and writes the cache. Cache invalidation is the caller’s responsibility.

make_aoo_polygons(aoo_grid, **kwargs)

Create AOOGridPolygons (grid cell × ecosystem intersections) from a computed local AOOGrid. For Earth Engine grids, use the rle.gee backend’s .to_polygons().

slugify_ecosystem_name(name)

Sanitize an ecosystem name into a valid DataFrame column name (non-alphanumeric characters become _). Used to name the per-ecosystem fraction columns.

AOOGrid

Abstract base class for AOO grid computations. Grid cells are 10×10 km (AOO_CELL_SIZE_M = 10_000), 100 km² each.

Classmethods: AOOGrid.from_file(...), from_parquet(...), from_cog(...).

AOOGridVectorLocal / AOOGridCOG

Concrete AOO grids for local vector data (GeoJSON/GeoParquet) and Cloud Optimized GeoTIFFs respectively.

AOOGridPolygons

Abstract base for grid × ecosystem intersection polygons.

AOOGridPolygonVectorLocal

Intersection polygons computed locally via shapely.

Errors


Ecosystem codes

Importable from rle.core.ecosystem_codes (not the top-level namespace).

assign_ecosystem_codes(gdf, *, fg_code_col, eco_name_col, eco_code_col)

Return a copy of gdf with a new hierarchical ecosystem-code column. Within each functional group, distinct ecosystem names are sorted alphabetically before numbering (T1.1T1.1.1, T1.1.2). Null functional group or name → null code.

Raises ValueError if a source column is missing or the target column already exists. Warns (UserWarning) when a generated code exceeds SHAPEFILE_VALUE_LIMIT (10 characters). See Ecosystem codes.


Backend registry

BackendInfo

Frozen dataclass describing a backend: name, cls, capability ("ecosystems" / "aoo" / "eoo"), distribution, can_handle.

iter_backends()

Return every BackendInfo advertised by installed rle.backends entry points.

list_backends()

Return the sorted names of all installed backends.


Command-line interface

The rle console script (rle.core.cli:app):

See CLI & backends.