This page runs a full assessment end to end on a small bundled dataset,
data/null_island.geojson — three toy ecosystems centered on 0°N, 0°E (a
tropical forest, an alpine grassland, and a marine shelf).
Load an ecosystem dataset¶
Every workflow starts with an Ecosystems object. The ecosystem_column
argument names the attribute that identifies each ecosystem type.
from rle.core import Ecosystems
eco = Ecosystems.from_file(
"data/null_island.geojson",
ecosystem_column="ECO_NAME",
)from rle.core import Ecosystems
eco = Ecosystems.from_file(
"https://data.source.coop/tyler/colombia-ecosystems-map/ecosistemas/ECOSISTEMAS_MEC_122024_5records.parquet",
ecosystem_column="ecos_general",
)
ecoInspect what was loaded:
print("features:", eco.size())
eco.unique_ecosystems()---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/registry.py:268, in get_filesystem_class(protocol)
267 try:
--> 268 register_implementation(protocol, _import_class(bit["class"]))
269 except ImportError as e:
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/registry.py:303, in _import_class(fqp)
302 is_s3 = mod == "s3fs"
--> 303 mod = importlib.import_module(mod)
304 if is_s3 and mod.__version__.split(".") < ["0", "5"]:
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/importlib/__init__.py:90, in import_module(name, package)
89 level += 1
---> 90 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:1334, in _find_and_load_unlocked(name, import_)
File <frozen importlib._bootstrap>:950, in _load_unlocked(spec)
File <frozen importlib._bootstrap_external>:999, in _LoaderBasics.exec_module(self, module)
File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/implementations/http.py:9
7 from urllib.parse import urlparse
----> 9 import aiohttp
10 import yarl
ModuleNotFoundError: No module named 'aiohttp'
The above exception was the direct cause of the following exception:
ImportError Traceback (most recent call last)
Cell In[3], line 1
----> 1 print("features:", eco.size())
2 eco.unique_ecosystems()
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/rle/core/ecosystems.py:115, in Ecosystems.size(self)
113 def size(self) -> int:
114 """Return the number of features."""
--> 115 data = self.load()
116 if hasattr(data, '__len__'):
117 return len(data)
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/rle/core/ecosystems.py:83, in Ecosystems.load(self)
81 """Load and cache the ecosystem data. Returns the native object."""
82 if self._cached is None:
---> 83 self._cached = self._load()
84 return self._cached
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/rle/core/ecosystems.py:678, in EcosystemsGeoParquet._load(self)
673 if isinstance(self._data, str) and self._data.startswith(
674 ("http://", "https://", "gs://", "s3://", "az://")
675 ):
676 import fsspec
--> 678 with fsspec.open(self._data, "rb") as f:
679 return gpd.read_parquet(f)
680 return gpd.read_parquet(self._data)
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/core.py:508, in open(urlpath, mode, compression, encoding, errors, protocol, newline, expand, **kwargs)
450 """Given a path or paths, return one ``OpenFile`` object.
451
452 Parameters
(...) 505 https://filesystem-spec.readthedocs.io/en/latest/api.html#other-known-implementations
506 """
507 expand = DEFAULT_EXPAND if expand is None else expand
--> 508 out = open_files(
509 urlpath=[urlpath],
510 mode=mode,
511 compression=compression,
512 encoding=encoding,
513 errors=errors,
514 protocol=protocol,
515 newline=newline,
516 expand=expand,
517 **kwargs,
518 )
519 if not out:
520 raise FileNotFoundError(urlpath)
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/core.py:295, in open_files(urlpath, mode, compression, encoding, errors, name_function, num, protocol, newline, auto_mkdir, expand, **kwargs)
216 def open_files(
217 urlpath,
218 mode="rb",
(...) 228 **kwargs,
229 ):
230 """Given a path or paths, return a list of ``OpenFile`` objects.
231
232 For writing, a str path must contain the "*" character, which will be filled
(...) 293 https://filesystem-spec.readthedocs.io/en/latest/api.html#other-known-implementations
294 """
--> 295 fs, fs_token, paths = get_fs_token_paths(
296 urlpath,
297 mode,
298 num=num,
299 name_function=name_function,
300 storage_options=kwargs,
301 protocol=protocol,
302 expand=expand,
303 )
304 if fs.protocol == "file":
305 fs.auto_mkdir = auto_mkdir
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/core.py:672, in get_fs_token_paths(urlpath, mode, num, name_function, storage_options, protocol, expand)
670 if protocol:
671 storage_options["protocol"] = protocol
--> 672 chain = _un_chain(urlpath0, storage_options or {})
673 inkwargs = {}
674 # Reverse iterate the chain, creating a nested target_* structure
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/core.py:358, in _un_chain(path, kwargs)
356 for bit in reversed(bits):
357 protocol = kwargs.pop("protocol", None) or split_protocol(bit)[0] or "file"
--> 358 cls = get_filesystem_class(protocol)
359 extra_kwargs = cls._get_kwargs_from_urls(bit)
360 kws = kwargs.pop(protocol, {})
File /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages/fsspec/registry.py:270, in get_filesystem_class(protocol)
268 register_implementation(protocol, _import_class(bit["class"]))
269 except ImportError as e:
--> 270 raise ImportError(bit.get("err")) from e
271 cls = registry[protocol]
272 if getattr(cls, "protocol", None) in ("abstract", None):
ImportError: HTTPFileSystem requires "requests" and "aiohttp" to be installedfrom_file picks a backend from the file extension (GeoParquet routes to the
GeoParquet backend; everything else is read as a vector file). See
Ecosystems for the full data model.
Area of Occupancy (AOO)¶
make_aoo_grid overlays the standard 10×10 km RLE grid on the ecosystem. Call
.compute() to run it, then read the derived properties.
from rle.core import make_aoo_grid
aoo = make_aoo_grid(eco).compute()
print("occupied cells:", aoo.cell_count)
print("AOO:", aoo.aoo_km2, "km²")Each occupied grid cell covers 100 km², so aoo_km2 is simply
cell_count × 100. AOO feeds RLE Criterion B2.
Extent of Occurrence (EOO)¶
make_eoo computes the convex hull of all occurrences and reports its area in an
equal-area projection.
from rle.core import make_eoo
eoo = make_eoo(eco).compute()
print("EOO:", round(eoo.area_km2, 2), "km²")EOO feeds RLE Criterion B1.
Next steps¶
Explore the data model — filtering, export, rasterization → Ecosystems
Go deeper on the metrics — grid fractions, caching, intersection polygons → Assessment metrics
See every public function → API reference