rle-python 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rle/core/__init__.py +77 -0
- rle/core/_entrypoints.py +51 -0
- rle/core/aoo.py +815 -0
- rle/core/aoo_grid.py +54 -0
- rle/core/cli.py +49 -0
- rle/core/ecosystem_codes.py +108 -0
- rle/core/ecosystems.py +690 -0
- rle/core/eoo.py +243 -0
- rle/core/registry.py +62 -0
- rle/core/rle.py +71 -0
- rle/core/viz.py +183 -0
- rle_python-0.2.0.dist-info/METADATA +96 -0
- rle_python-0.2.0.dist-info/RECORD +16 -0
- rle_python-0.2.0.dist-info/WHEEL +4 -0
- rle_python-0.2.0.dist-info/entry_points.txt +5 -0
- rle_python-0.2.0.dist-info/licenses/LICENSE +201 -0
rle/core/__init__.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""RLE core — IUCN Red List of Ecosystems analysis with local/cloud data access.
|
|
2
|
+
|
|
3
|
+
This is the backend-agnostic core. It provides the RLE data model
|
|
4
|
+
(``Ecosystems``, ``AOOGrid``, ``EOO``), the assessment business logic, and
|
|
5
|
+
local + cloud-file (``gs://``, ``s3://`` via fsspec) data access.
|
|
6
|
+
|
|
7
|
+
Earth Engine support lives in the optional ``rle-python-gee`` distribution
|
|
8
|
+
(import ``rle.gee``).
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
__version__ = version("rle-python")
|
|
15
|
+
except PackageNotFoundError:
|
|
16
|
+
__version__ = "0.0.0.dev"
|
|
17
|
+
|
|
18
|
+
from rle.core.ecosystems import (
|
|
19
|
+
Ecosystems,
|
|
20
|
+
EcosystemKind,
|
|
21
|
+
EcosystemsFile,
|
|
22
|
+
EcosystemsGeoParquet,
|
|
23
|
+
EcosystemsGeoDataFrame,
|
|
24
|
+
EcosystemsCOG,
|
|
25
|
+
)
|
|
26
|
+
from rle.core.eoo import (
|
|
27
|
+
EOO,
|
|
28
|
+
EOOVectorLocal,
|
|
29
|
+
EOONotComputedError,
|
|
30
|
+
make_eoo,
|
|
31
|
+
)
|
|
32
|
+
from rle.core.aoo import (
|
|
33
|
+
AOOGrid,
|
|
34
|
+
AOOGridVectorLocal,
|
|
35
|
+
AOOGridCOG,
|
|
36
|
+
AOOGridNotComputedError,
|
|
37
|
+
AOOGridPolygons,
|
|
38
|
+
AOOGridPolygonVectorLocal,
|
|
39
|
+
AOOGridPolygonsNotComputedError,
|
|
40
|
+
make_aoo_grid,
|
|
41
|
+
make_aoo_grid_cached,
|
|
42
|
+
make_aoo_polygons,
|
|
43
|
+
slugify_ecosystem_name,
|
|
44
|
+
)
|
|
45
|
+
from rle.core.registry import BackendInfo, iter_backends, list_backends
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"__version__",
|
|
49
|
+
# data model
|
|
50
|
+
"Ecosystems",
|
|
51
|
+
"EcosystemKind",
|
|
52
|
+
"EcosystemsFile",
|
|
53
|
+
"EcosystemsGeoParquet",
|
|
54
|
+
"EcosystemsGeoDataFrame",
|
|
55
|
+
"EcosystemsCOG",
|
|
56
|
+
# EOO
|
|
57
|
+
"EOO",
|
|
58
|
+
"EOOVectorLocal",
|
|
59
|
+
"EOONotComputedError",
|
|
60
|
+
"make_eoo",
|
|
61
|
+
# AOO
|
|
62
|
+
"AOOGrid",
|
|
63
|
+
"AOOGridVectorLocal",
|
|
64
|
+
"AOOGridCOG",
|
|
65
|
+
"AOOGridNotComputedError",
|
|
66
|
+
"AOOGridPolygons",
|
|
67
|
+
"AOOGridPolygonVectorLocal",
|
|
68
|
+
"AOOGridPolygonsNotComputedError",
|
|
69
|
+
"make_aoo_grid",
|
|
70
|
+
"make_aoo_grid_cached",
|
|
71
|
+
"make_aoo_polygons",
|
|
72
|
+
"slugify_ecosystem_name",
|
|
73
|
+
# discovery
|
|
74
|
+
"BackendInfo",
|
|
75
|
+
"iter_backends",
|
|
76
|
+
"list_backends",
|
|
77
|
+
]
|
rle/core/_entrypoints.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Entry-point registration for the core (local/cloud-file) backends."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from rle.core.registry import BackendInfo
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _is_geojson(data) -> bool:
|
|
9
|
+
return isinstance(data, str) and data.endswith((".geojson", ".json"))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def _is_geoparquet(data) -> bool:
|
|
13
|
+
return isinstance(data, str) and data.endswith(".parquet")
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _is_cog(data) -> bool:
|
|
17
|
+
return isinstance(data, str) and data.endswith((".tif", ".tiff"))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def register() -> list[BackendInfo]:
|
|
21
|
+
"""Advertise the local/cloud-file ecosystem backends provided by rle-python."""
|
|
22
|
+
from rle.core.ecosystems import (
|
|
23
|
+
EcosystemsFile,
|
|
24
|
+
EcosystemsGeoParquet,
|
|
25
|
+
EcosystemsCOG,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
dist = "rle-python"
|
|
29
|
+
return [
|
|
30
|
+
BackendInfo(
|
|
31
|
+
name="file",
|
|
32
|
+
cls=EcosystemsFile,
|
|
33
|
+
capability="ecosystems",
|
|
34
|
+
distribution=dist,
|
|
35
|
+
can_handle=_is_geojson,
|
|
36
|
+
),
|
|
37
|
+
BackendInfo(
|
|
38
|
+
name="geoparquet",
|
|
39
|
+
cls=EcosystemsGeoParquet,
|
|
40
|
+
capability="ecosystems",
|
|
41
|
+
distribution=dist,
|
|
42
|
+
can_handle=_is_geoparquet,
|
|
43
|
+
),
|
|
44
|
+
BackendInfo(
|
|
45
|
+
name="cog",
|
|
46
|
+
cls=EcosystemsCOG,
|
|
47
|
+
capability="ecosystems",
|
|
48
|
+
distribution=dist,
|
|
49
|
+
can_handle=_is_cog,
|
|
50
|
+
),
|
|
51
|
+
]
|