openforis-whisp 2.0.0a4__py3-none-any.whl → 2.0.0a6__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.
- openforis_whisp/__init__.py +75 -75
- openforis_whisp/data_conversion.py +493 -371
- openforis_whisp/datasets.py +1384 -1381
- openforis_whisp/logger.py +75 -75
- openforis_whisp/parameters/__init__.py +15 -15
- openforis_whisp/parameters/config_runtime.py +44 -44
- openforis_whisp/parameters/lookup_context_and_metadata.csv +13 -13
- openforis_whisp/parameters/lookup_gee_datasets.csv +1 -1
- openforis_whisp/pd_schemas.py +77 -77
- openforis_whisp/reformat.py +495 -495
- openforis_whisp/risk.py +771 -777
- openforis_whisp/stats.py +1134 -953
- openforis_whisp/utils.py +154 -154
- {openforis_whisp-2.0.0a4.dist-info → openforis_whisp-2.0.0a6.dist-info}/LICENSE +21 -21
- {openforis_whisp-2.0.0a4.dist-info → openforis_whisp-2.0.0a6.dist-info}/METADATA +37 -46
- openforis_whisp-2.0.0a6.dist-info/RECORD +17 -0
- {openforis_whisp-2.0.0a4.dist-info → openforis_whisp-2.0.0a6.dist-info}/WHEEL +1 -1
- openforis_whisp-2.0.0a4.dist-info/RECORD +0 -17
openforis_whisp/utils.py
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
import ee
|
|
3
|
-
import math
|
|
4
|
-
import os
|
|
5
|
-
import pandas as pd
|
|
6
|
-
|
|
7
|
-
import importlib.resources as pkg_resources
|
|
8
|
-
|
|
9
|
-
from dotenv import load_dotenv
|
|
10
|
-
from pathlib import Path
|
|
11
|
-
|
|
12
|
-
from .logger import StdoutLogger
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
logger = StdoutLogger(__name__)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def get_example_data_path(filename):
|
|
19
|
-
"""
|
|
20
|
-
Get the path to an example data file included in the package.
|
|
21
|
-
|
|
22
|
-
Parameters:
|
|
23
|
-
-----------
|
|
24
|
-
filename : str
|
|
25
|
-
The name of the example data file.
|
|
26
|
-
|
|
27
|
-
Returns:
|
|
28
|
-
--------
|
|
29
|
-
str
|
|
30
|
-
The path to the example data file.
|
|
31
|
-
"""
|
|
32
|
-
return os.path.join("..", "tests", "fixtures", filename)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def load_env_vars() -> None:
|
|
36
|
-
"""Loads the environment variables required for testing the codebase.
|
|
37
|
-
|
|
38
|
-
Returns
|
|
39
|
-
-------
|
|
40
|
-
out : None
|
|
41
|
-
"""
|
|
42
|
-
|
|
43
|
-
all_dotenv_paths = [Path(__file__).parents[2] / ".env", Path.cwd() / ".env"]
|
|
44
|
-
dotenv_loaded = False
|
|
45
|
-
|
|
46
|
-
for dotenv_path in all_dotenv_paths:
|
|
47
|
-
logger.logger.debug(f"dotenv_path: {dotenv_path}")
|
|
48
|
-
if dotenv_path.exists():
|
|
49
|
-
dotenv_loaded = load_dotenv(dotenv_path)
|
|
50
|
-
break
|
|
51
|
-
|
|
52
|
-
if not dotenv_loaded:
|
|
53
|
-
raise DotEnvNotFoundError
|
|
54
|
-
logger.logger.info(f"Loaded evironment variables from '{dotenv_path}'")
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def init_ee() -> None:
|
|
58
|
-
"""Initialize earth engine according to the environment"""
|
|
59
|
-
|
|
60
|
-
# only do the initialization if the credential are missing
|
|
61
|
-
if not ee.data._credentials:
|
|
62
|
-
|
|
63
|
-
# if in test env use the private key
|
|
64
|
-
if "EE_PRIVATE_KEY" in os.environ:
|
|
65
|
-
|
|
66
|
-
# key need to be decoded in a file
|
|
67
|
-
content = base64.b64decode(os.environ["EE_PRIVATE_KEY"]).decode()
|
|
68
|
-
with open("ee_private_key.json", "w") as f:
|
|
69
|
-
f.write(content)
|
|
70
|
-
|
|
71
|
-
# connection to the service account
|
|
72
|
-
service_account = "test-sepal-ui@sepal-ui.iam.gserviceaccount.com"
|
|
73
|
-
credentials = ee.ServiceAccountCredentials(
|
|
74
|
-
service_account, "ee_private_key.json"
|
|
75
|
-
)
|
|
76
|
-
ee.Initialize(credentials)
|
|
77
|
-
logger.logger.info(f"Used env var")
|
|
78
|
-
|
|
79
|
-
# if in local env use the local user credential
|
|
80
|
-
else:
|
|
81
|
-
try:
|
|
82
|
-
load_env_vars()
|
|
83
|
-
logger.logger.info("Called 'ee.Initialize()'.")
|
|
84
|
-
ee.Initialize(project=os.environ["PROJECT"])
|
|
85
|
-
except ee.ee_exception.EEException:
|
|
86
|
-
logger.logger.info("Called 'ee.Authenticate()'.")
|
|
87
|
-
ee.Authenticate()
|
|
88
|
-
ee.Initialize(project=os.environ["PROJECT"])
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def clear_ee_credentials():
|
|
92
|
-
|
|
93
|
-
path_to_creds = Path().home() / ".config" / "earthengine" / "credentials"
|
|
94
|
-
if not path_to_creds.exists():
|
|
95
|
-
logger.logger.error(
|
|
96
|
-
f"GEE credentials file '{path_to_creds}' not found, could not de-authenticate."
|
|
97
|
-
)
|
|
98
|
-
else:
|
|
99
|
-
path_to_creds.unlink()
|
|
100
|
-
logger.logger.warning(f"GEE credentials file deleted.")
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def remove_geometry_from_feature_collection(feature_collection):
|
|
104
|
-
"""Define the function to remove geometry from features in a feature collection"""
|
|
105
|
-
# Function to remove geometry from features
|
|
106
|
-
def remove_geometry(feature):
|
|
107
|
-
# Remove the geometry property
|
|
108
|
-
feature = feature.setGeometry(None)
|
|
109
|
-
return feature
|
|
110
|
-
|
|
111
|
-
# Apply the function to remove geometry to the feature collection
|
|
112
|
-
feature_collection_no_geometry = feature_collection.map(remove_geometry)
|
|
113
|
-
return feature_collection_no_geometry
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
# Compute centroids of each polygon
|
|
117
|
-
def get_centroid(feature,
|
|
118
|
-
keepProperties = [
|
|
119
|
-
# Get the centroid of the feature's geometry.
|
|
120
|
-
centroid = feature.geometry().centroid(1)
|
|
121
|
-
# Return a new Feature, copying properties from the old Feature.
|
|
122
|
-
return ee.Feature(centroid).copyProperties(feature, keepProperties)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def buffer_point_to_required_area(feature, area, area_unit):
|
|
126
|
-
"""buffers feature to get a given area (needs math library); area unit in 'ha' or 'km2' (the default)"""
|
|
127
|
-
area = feature.get("REP_AREA")
|
|
128
|
-
|
|
129
|
-
# buffer_size = get_radius_m_to_buffer_for_given_area(area,"km2")# should work but untested in this function
|
|
130
|
-
|
|
131
|
-
buffer_size = (
|
|
132
|
-
(ee.Number(feature.get("REP_AREA")).divide(math.pi)).sqrt().multiply(1000)
|
|
133
|
-
) # calculating radius in metres from REP_AREA in km2
|
|
134
|
-
|
|
135
|
-
return ee.Feature(feature).buffer(buffer_size, 1)
|
|
136
|
-
### buffering (incl., max error parameter should be 0m. But put as 1m anyhow - doesn't seem to make too much of a difference for speed)
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
def get_radius_m_to_buffer_to_required_area(area, area_unit="km2"):
|
|
140
|
-
"""gets radius in metres to buffer to get an area (needs math library); area unit ha or km2 (the default)"""
|
|
141
|
-
if area_unit == "km2":
|
|
142
|
-
unit_fix_factor = 1000
|
|
143
|
-
elif area_unit == "ha":
|
|
144
|
-
unit_fix_factor = 100
|
|
145
|
-
radius = ee.Number(area).divide(math.pi).sqrt().multiply(unit_fix_factor)
|
|
146
|
-
return radius
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
class DotEnvNotFoundError(FileNotFoundError):
|
|
150
|
-
def __init__(self) -> None:
|
|
151
|
-
super().__init__(
|
|
152
|
-
"Running tests requires setting an appropriate '.env' in the root directory or in your current working "
|
|
153
|
-
"directory. You may copy and edit the '.env.template' file from the root directory or from the README.",
|
|
154
|
-
)
|
|
1
|
+
import base64
|
|
2
|
+
import ee
|
|
3
|
+
import math
|
|
4
|
+
import os
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
import importlib.resources as pkg_resources
|
|
8
|
+
|
|
9
|
+
from dotenv import load_dotenv
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from .logger import StdoutLogger
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
logger = StdoutLogger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_example_data_path(filename):
|
|
19
|
+
"""
|
|
20
|
+
Get the path to an example data file included in the package.
|
|
21
|
+
|
|
22
|
+
Parameters:
|
|
23
|
+
-----------
|
|
24
|
+
filename : str
|
|
25
|
+
The name of the example data file.
|
|
26
|
+
|
|
27
|
+
Returns:
|
|
28
|
+
--------
|
|
29
|
+
str
|
|
30
|
+
The path to the example data file.
|
|
31
|
+
"""
|
|
32
|
+
return os.path.join("..", "tests", "fixtures", filename)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def load_env_vars() -> None:
|
|
36
|
+
"""Loads the environment variables required for testing the codebase.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
out : None
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
all_dotenv_paths = [Path(__file__).parents[2] / ".env", Path.cwd() / ".env"]
|
|
44
|
+
dotenv_loaded = False
|
|
45
|
+
|
|
46
|
+
for dotenv_path in all_dotenv_paths:
|
|
47
|
+
logger.logger.debug(f"dotenv_path: {dotenv_path}")
|
|
48
|
+
if dotenv_path.exists():
|
|
49
|
+
dotenv_loaded = load_dotenv(dotenv_path)
|
|
50
|
+
break
|
|
51
|
+
|
|
52
|
+
if not dotenv_loaded:
|
|
53
|
+
raise DotEnvNotFoundError
|
|
54
|
+
logger.logger.info(f"Loaded evironment variables from '{dotenv_path}'")
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def init_ee() -> None:
|
|
58
|
+
"""Initialize earth engine according to the environment"""
|
|
59
|
+
|
|
60
|
+
# only do the initialization if the credential are missing
|
|
61
|
+
if not ee.data._credentials:
|
|
62
|
+
|
|
63
|
+
# if in test env use the private key
|
|
64
|
+
if "EE_PRIVATE_KEY" in os.environ:
|
|
65
|
+
|
|
66
|
+
# key need to be decoded in a file
|
|
67
|
+
content = base64.b64decode(os.environ["EE_PRIVATE_KEY"]).decode()
|
|
68
|
+
with open("ee_private_key.json", "w") as f:
|
|
69
|
+
f.write(content)
|
|
70
|
+
|
|
71
|
+
# connection to the service account
|
|
72
|
+
service_account = "test-sepal-ui@sepal-ui.iam.gserviceaccount.com"
|
|
73
|
+
credentials = ee.ServiceAccountCredentials(
|
|
74
|
+
service_account, "ee_private_key.json"
|
|
75
|
+
)
|
|
76
|
+
ee.Initialize(credentials)
|
|
77
|
+
logger.logger.info(f"Used env var")
|
|
78
|
+
|
|
79
|
+
# if in local env use the local user credential
|
|
80
|
+
else:
|
|
81
|
+
try:
|
|
82
|
+
load_env_vars()
|
|
83
|
+
logger.logger.info("Called 'ee.Initialize()'.")
|
|
84
|
+
ee.Initialize(project=os.environ["PROJECT"])
|
|
85
|
+
except ee.ee_exception.EEException:
|
|
86
|
+
logger.logger.info("Called 'ee.Authenticate()'.")
|
|
87
|
+
ee.Authenticate()
|
|
88
|
+
ee.Initialize(project=os.environ["PROJECT"])
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def clear_ee_credentials():
|
|
92
|
+
|
|
93
|
+
path_to_creds = Path().home() / ".config" / "earthengine" / "credentials"
|
|
94
|
+
if not path_to_creds.exists():
|
|
95
|
+
logger.logger.error(
|
|
96
|
+
f"GEE credentials file '{path_to_creds}' not found, could not de-authenticate."
|
|
97
|
+
)
|
|
98
|
+
else:
|
|
99
|
+
path_to_creds.unlink()
|
|
100
|
+
logger.logger.warning(f"GEE credentials file deleted.")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def remove_geometry_from_feature_collection(feature_collection):
|
|
104
|
+
"""Define the function to remove geometry from features in a feature collection"""
|
|
105
|
+
# Function to remove geometry from features
|
|
106
|
+
def remove_geometry(feature):
|
|
107
|
+
# Remove the geometry property
|
|
108
|
+
feature = feature.setGeometry(None)
|
|
109
|
+
return feature
|
|
110
|
+
|
|
111
|
+
# Apply the function to remove geometry to the feature collection
|
|
112
|
+
feature_collection_no_geometry = feature_collection.map(remove_geometry)
|
|
113
|
+
return feature_collection_no_geometry
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
# Compute centroids of each polygon including the external_id_column
|
|
117
|
+
def get_centroid(feature, external_id_column="external_id"):
|
|
118
|
+
keepProperties = [external_id_column]
|
|
119
|
+
# Get the centroid of the feature's geometry.
|
|
120
|
+
centroid = feature.geometry().centroid(1)
|
|
121
|
+
# Return a new Feature, copying properties from the old Feature.
|
|
122
|
+
return ee.Feature(centroid).copyProperties(feature, keepProperties)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def buffer_point_to_required_area(feature, area, area_unit):
|
|
126
|
+
"""buffers feature to get a given area (needs math library); area unit in 'ha' or 'km2' (the default)"""
|
|
127
|
+
area = feature.get("REP_AREA")
|
|
128
|
+
|
|
129
|
+
# buffer_size = get_radius_m_to_buffer_for_given_area(area,"km2")# should work but untested in this function
|
|
130
|
+
|
|
131
|
+
buffer_size = (
|
|
132
|
+
(ee.Number(feature.get("REP_AREA")).divide(math.pi)).sqrt().multiply(1000)
|
|
133
|
+
) # calculating radius in metres from REP_AREA in km2
|
|
134
|
+
|
|
135
|
+
return ee.Feature(feature).buffer(buffer_size, 1)
|
|
136
|
+
### buffering (incl., max error parameter should be 0m. But put as 1m anyhow - doesn't seem to make too much of a difference for speed)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def get_radius_m_to_buffer_to_required_area(area, area_unit="km2"):
|
|
140
|
+
"""gets radius in metres to buffer to get an area (needs math library); area unit ha or km2 (the default)"""
|
|
141
|
+
if area_unit == "km2":
|
|
142
|
+
unit_fix_factor = 1000
|
|
143
|
+
elif area_unit == "ha":
|
|
144
|
+
unit_fix_factor = 100
|
|
145
|
+
radius = ee.Number(area).divide(math.pi).sqrt().multiply(unit_fix_factor)
|
|
146
|
+
return radius
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class DotEnvNotFoundError(FileNotFoundError):
|
|
150
|
+
def __init__(self) -> None:
|
|
151
|
+
super().__init__(
|
|
152
|
+
"Running tests requires setting an appropriate '.env' in the root directory or in your current working "
|
|
153
|
+
"directory. You may copy and edit the '.env.template' file from the root directory or from the README.",
|
|
154
|
+
)
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 lecrabe
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 lecrabe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: openforis-whisp
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.0a6
|
|
4
4
|
Summary: Whisp (What is in that plot) is an open-source solution which helps to produce relevant forest monitoring information and support compliance with deforestation-related regulations.
|
|
5
5
|
License: MIT
|
|
6
6
|
Keywords: whisp,geospatial,data-processing
|
|
@@ -77,8 +77,6 @@ Description-Content-Type: text/markdown
|
|
|
77
77
|
|
|
78
78
|
|
|
79
79
|
## Whisp datasets <a name="whisp_datasets"></a>
|
|
80
|
-
All output columns from Whisp are described in [this excel file](https://github.com/forestdatapartnership/whisp/blob/main/whisp_columns.xlsx)
|
|
81
|
-
|
|
82
80
|
***Whisp*** implements the convergence of evidence approach by providing a transparent and public processing flow using datasets covering the following categories:
|
|
83
81
|
|
|
84
82
|
1) Tree and forest cover (at the end of 2020);
|
|
@@ -86,27 +84,39 @@ Description-Content-Type: text/markdown
|
|
|
86
84
|
3) Disturbances **before 2020** (i.e., degradation or deforestation until 2020-12-31);
|
|
87
85
|
4) Disturbances **after 2020** (i.e., degradation or deforestation from 2021-01-01 onward).
|
|
88
86
|
|
|
87
|
+
Additional categories are specific for the timber commodity, considering a harvesting date in 2023:
|
|
88
|
+
|
|
89
|
+
5) Primary forests in 2020;
|
|
90
|
+
6) Naturally regenerating forests in 2020;
|
|
91
|
+
7) Planted and plantation forests in 2020;
|
|
92
|
+
8) Planted and plantation forests in 2023;
|
|
93
|
+
9) Treecover in 2023;
|
|
94
|
+
10) Commodities or croplands in 2023.
|
|
95
|
+
11) Logging concessions;
|
|
96
|
+
|
|
89
97
|
There are multiple datasets for each category. Find the full current [list of datasets used in Whisp here](https://github.com/forestdatapartnership/whisp/blob/main/layers_description.md).
|
|
90
|
-
|
|
98
|
+
|
|
99
|
+
### Whisp risk assessment <a name="whisp_risk"></a>
|
|
100
|
+
|
|
101
|
+
Whisp checks the plots provided by the user by running zonal statistics on them to answer the following questions:
|
|
91
102
|
|
|
92
103
|
1) Was there tree cover in 2020?
|
|
93
104
|
2) Were there commodity plantations or other agricultural uses in 2020?
|
|
94
105
|
3) Were there disturbances until 2020-12-31?
|
|
95
106
|
4) Were there disturbances after 2020-12-31 / starting 2021-01-01?
|
|
96
107
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
If one or more treecover datasets indicate tree cover on a plot by the end of 2020, but a commodity dataset indicates agricultural use by the end of 2020, **Whisp will categorize the deforestation risk as low.**
|
|
100
|
-
|
|
101
|
-
If treecover datasets indicate tree cover on a plot by late 2020, no commodity datasets indicate agricultural use, but a disturbance dataset indicates disturbances before the end of 2020, **Whisp will categorize the deforestation risk as <u>low</u>.** Such deforestation has happened before 2020, which aligns with the cutoff date for legislation such as EUDR, and is therefore not considered high risk.
|
|
102
|
-
|
|
103
|
-
Now, if the datasets under 1., 2. & 3. indicate that there was tree cover, but no agriculture and no disturbances before or by the end of 2020, the Whisp algorithm checks whether degradation or deforestation have been reported in a disturbance dataset after 2020-12-31. If they have, **Whisp will categorize the deforestation risk as <u>high</u>.** <br>
|
|
104
|
-
However, under the same circumstances but with <u>no</u> disturbances reported after 2020-12-31 there is insufficient evidence and the **Whisp output will be "More info needed".** Such can be the case for, e.g., cocoa or coffee grown under the shade of treecover or agroforestry.
|
|
108
|
+
And specifically for the timber commodity, considering a harvesting date in 2023:
|
|
105
109
|
|
|
110
|
+
5) Were there primary forests in 2020?
|
|
111
|
+
6) Were there naturally regenerating forests in 2020?
|
|
112
|
+
7) Were there planted and plantation forests in 2020?
|
|
113
|
+
8) Were there planted and plantation forests in 2023?
|
|
114
|
+
9) Was there treecover in 2023?
|
|
115
|
+
10) Were there commodity plantations or other agricultural uses in 2023?
|
|
116
|
+
11) Is it part of a logging concession?
|
|
106
117
|
|
|
107
|
-
*The Whisp algorithm for **Perennial Crops** visualized:*
|
|
108
|
-

|
|
109
118
|
The Whisp algorithm outputs multiple statistical columns with disaggregated data from the input datasets, followed by aggregated indicator columns, and the final risk assessment columns.
|
|
119
|
+
All output columns from Whisp are described in [this excel file](https://github.com/forestdatapartnership/whisp/blob/main/whisp_columns.xlsx)
|
|
110
120
|
|
|
111
121
|
The **relevant risk assessment column depends on the commodity** in question:
|
|
112
122
|
|
|
@@ -141,47 +151,28 @@ The **relevant risk assessment column depends on the commodity** in question:
|
|
|
141
151
|
</tr>
|
|
142
152
|
</table>
|
|
143
153
|
|
|
144
|
-
The
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
*The Whisp algorithm for **Perennial Crops** visualized:*
|
|
155
|
+

|
|
156
|
+
|
|
157
|
+
If no treecover dataset indicates any tree cover for a plot by the end of 2020, **Whisp will categorize the deforestation risk as low.**
|
|
147
158
|
|
|
159
|
+
If one or more treecover datasets indicate tree cover on a plot by the end of 2020, but a commodity dataset indicates agricultural use by the end of 2020, **Whisp will categorize the deforestation risk as low.**
|
|
148
160
|
|
|
149
|
-
|
|
150
|
-
***Whisp*** implements the convergence of evidence approach by providing a transparent and public processing flow using datasets covering the following categories:
|
|
151
|
-
1) Tree and forest cover (at the end of 2020);
|
|
152
|
-
2) Commodities (i.e., crop plantations and other agricultural uses at the end of 2020);
|
|
153
|
-
3) Disturbances **before 2020** (i.e., degradation or deforestation until 2020-12-31);
|
|
154
|
-
4) Disturbances **after 2020** (i.e., degradation or deforestation from 2021-01-01 onward).
|
|
155
|
-
5) Primary forests in 2020;
|
|
156
|
-
6) Naturally regenerating forests in 2020;
|
|
157
|
-
7) Planted and plantation forests in 2020;
|
|
158
|
-
8) Planted and plantation forests in 2023;
|
|
159
|
-
9) Treecover in 2023;
|
|
160
|
-
10) Commodities or croplands in 2023.
|
|
161
|
-
11) Logging concessions;
|
|
161
|
+
If treecover datasets indicate tree cover on a plot by late 2020, no commodity datasets indicate agricultural use, but a disturbance dataset indicates disturbances before the end of 2020, **Whisp will categorize the deforestation risk as <u>low</u>.** Such deforestation has happened before 2020, which aligns with the cutoff date for legislation such as EUDR, and is therefore not considered high risk.
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
Now, if the datasets under 1., 2. & 3. indicate that there was tree cover, but no agriculture and no disturbances before or by the end of 2020, the Whisp algorithm checks whether degradation or deforestation have been reported in a disturbance dataset after 2020-12-31. If they have, **Whisp will categorize the deforestation risk as <u>high</u>.** <br>
|
|
164
|
+
However, under the same circumstances but with <u>no</u> disturbances reported after 2020-12-31 there is insufficient evidence and the **Whisp output will be "More info needed".** Such can be the case for, e.g., cocoa or coffee grown under the shade of treecover or agroforestry.
|
|
165
165
|
|
|
166
|
-
1) Was there tree cover in 2020?
|
|
167
|
-
2) Were there commodity plantations or other agricultural uses in 2020?
|
|
168
|
-
3) Were there disturbances until 2020-12-31?
|
|
169
|
-
4) Were there disturbances after 2020-12-31 / starting 2021-01-01?
|
|
170
|
-
5) Were there primary forests in 2020?
|
|
171
|
-
6) Were there naturally regenerating forests in 2020?
|
|
172
|
-
7) Were there planted and plantation forests in 2020?
|
|
173
|
-
8) Were there planted and plantation forests in 2023?
|
|
174
|
-
9) Was there treecover in 2023?
|
|
175
|
-
10) Were there commodity plantations or other agricultural uses in 2023?
|
|
176
|
-
11) Were there logging concessions?
|
|
177
166
|
|
|
178
|
-
|
|
167
|
+
## Run Whisp python package from a notebook <a name="whisp_notebooks"></a>
|
|
179
168
|
|
|
180
169
|
For most users we suggest using the Whisp App to process their plot data. But for some, using the python package directly will fit their workflow.
|
|
181
170
|
|
|
182
171
|
A simple example of the package functionality can be seen in this [Colab Notebook](https://github.com/forestdatapartnership/whisp/blob/main/notebooks/Colab_whisp_geojson_to_csv.ipynb)
|
|
183
172
|
|
|
184
|
-
|
|
173
|
+
For an example notebook adapted for running locally (or in Sepal), see: [whisp_geojson_to_csv.ipynb](https://github.com/forestdatapartnership/whisp/blob/main/notebooks/whisp_geojson_to_csv.ipynb) or if datasets are very large, see [whisp_geojson_to_drive.ipynb](https://github.com/forestdatapartnership/whisp/blob/main/notebooks/whisp_geojson_to_drive.ipynb)
|
|
174
|
+
|
|
175
|
+
### Requirements for running the package
|
|
185
176
|
|
|
186
177
|
- A Google Earth Engine (GEE) account.
|
|
187
178
|
- A registered cloud GEE project.
|
|
@@ -190,7 +181,7 @@ The **relevant risk assessment column depends on the commodity** in question:
|
|
|
190
181
|
More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
|
|
191
182
|
|
|
192
183
|
|
|
193
|
-
|
|
184
|
+
### Python package installation
|
|
194
185
|
|
|
195
186
|
The Whisp package is available on pip
|
|
196
187
|
https://pypi.org/project/openforis-whisp/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
openforis_whisp/__init__.py,sha256=OOCc-TFeVPAdYb06jMNzHqpeLBhoaWKOvzhAe2QaeLE,2328
|
|
2
|
+
openforis_whisp/data_conversion.py,sha256=u4lJ39B22H2KBKDFEd-lgwH_IRW2MTldaOxFQjmDGA0,16416
|
|
3
|
+
openforis_whisp/datasets.py,sha256=aDwoPmO_MViiGjyqmn7Sp17YYxaz-_gDKEdslSCz0Zc,50629
|
|
4
|
+
openforis_whisp/logger.py,sha256=73Eppe-Rd8wtzUGswUNUY3jOaNrNHy0N7qJ1TxgLSKk,2233
|
|
5
|
+
openforis_whisp/parameters/__init__.py,sha256=1ThsS9HYwZJzBR_3_BWU2UkyVtzN9u4CgdnmuClt4ug,334
|
|
6
|
+
openforis_whisp/parameters/config_runtime.py,sha256=wm1dC9cuDkrNPBMMoncK2a4TKcwd8Jw47HY_zsUuk_0,1377
|
|
7
|
+
openforis_whisp/parameters/lookup_context_and_metadata.csv,sha256=_UQ8u7WOJH1ZHOGUVUNirfj-XdyALuLk_ele1ANSvZk,1285
|
|
8
|
+
openforis_whisp/parameters/lookup_gee_datasets.csv,sha256=5K1LQyuvwvG1vOdlyCknv_foDtRUKHPU3VvOU_zsoWQ,17626
|
|
9
|
+
openforis_whisp/pd_schemas.py,sha256=lTv7fbwwG9bGOi6M4-tsJ3xm_HpiWJW-fhrZ0ELUF2c,2604
|
|
10
|
+
openforis_whisp/reformat.py,sha256=ckSO8N_2GySe7X_Pot72N88wz2Y0RFIB774asWY69lc,17427
|
|
11
|
+
openforis_whisp/risk.py,sha256=DKfFN4RrqSkVDbDFcEEWjlFIiDfNO-XACSzxxI1MNNI,31182
|
|
12
|
+
openforis_whisp/stats.py,sha256=oNLr6yU5M-BY61L6NIcDUy93t1VwUTLEgnh8T6YyweA,39748
|
|
13
|
+
openforis_whisp/utils.py,sha256=jWfq12wiVxcnlPPAtfDy0scHwYwSNKANoY2rRsDYx88,5224
|
|
14
|
+
openforis_whisp-2.0.0a6.dist-info/LICENSE,sha256=RmwgaoqiMSysLXZaB9GP-f106r1F1OiC7dLKxjrfh20,1064
|
|
15
|
+
openforis_whisp-2.0.0a6.dist-info/METADATA,sha256=AbMJGBkxVId1lSEWTFRfRDoaieBqwLR_sR2sxTVPCVk,16681
|
|
16
|
+
openforis_whisp-2.0.0a6.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
17
|
+
openforis_whisp-2.0.0a6.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
openforis_whisp/__init__.py,sha256=xfXNzskPfnlQkmf3QZHEydhte3U9_uLdoYM04eowNqw,2403
|
|
2
|
-
openforis_whisp/data_conversion.py,sha256=Ean2SBxhGr1YwzhbrHQD9kDdRYdNTJZLBiAmYZtBIM8,11812
|
|
3
|
-
openforis_whisp/datasets.py,sha256=IXKvUe0R06Ha0K7ITYlRoOwSTEvE08qmRfx64HpbtX4,51915
|
|
4
|
-
openforis_whisp/logger.py,sha256=n9k0EhAZYZKesnfskv8KyWnkGbjqRqk84ulx9-u_Jsc,2308
|
|
5
|
-
openforis_whisp/parameters/__init__.py,sha256=KL7iORJVjSpZatYjoyWckcmQJnE89_DBC8R6_0_eR6o,349
|
|
6
|
-
openforis_whisp/parameters/config_runtime.py,sha256=aH00CFV09f7JQnZQzpCFR5BIlvsovVfM4K_KUjMl0N8,1416
|
|
7
|
-
openforis_whisp/parameters/lookup_context_and_metadata.csv,sha256=54uZ4oqfsiHgj2I39pAcsCr4SeSUqgIRboDhlxIAdik,1293
|
|
8
|
-
openforis_whisp/parameters/lookup_gee_datasets.csv,sha256=3YRG-ZvMAeekGTSvrDMyDnioOZUvy_iMbEaZcLhVPw0,17622
|
|
9
|
-
openforis_whisp/pd_schemas.py,sha256=W_ocS773LHfc05dJqvWRa-bRdX0wKFoNp0lMxgFx94Y,2681
|
|
10
|
-
openforis_whisp/reformat.py,sha256=o3TpeuddR1UlP1C3uFeI957kIZYMQqEW1pXsjKbAtiY,17922
|
|
11
|
-
openforis_whisp/risk.py,sha256=E9yZJ2wCinYrOydKK7EB0O5Imk5quG9Cs1uNkcv8AlM,31531
|
|
12
|
-
openforis_whisp/stats.py,sha256=yAa6j3RpkPIjAM06IKQ7XGaFrwXhxfzIXn37aTOEwP4,33562
|
|
13
|
-
openforis_whisp/utils.py,sha256=hpeY9aA3BND2m9c15PZ6_nClemsfiVNUEzA4pQXfztA,5330
|
|
14
|
-
openforis_whisp-2.0.0a4.dist-info/LICENSE,sha256=nqyqICO95iw_iwzP1t_IIAf7ZX3DPbL_M9WyQfh2q1k,1085
|
|
15
|
-
openforis_whisp-2.0.0a4.dist-info/METADATA,sha256=Xd8wihc9vGDwt5CLXtVTWy2urFSeWFGY_D2MlhCL8-c,17278
|
|
16
|
-
openforis_whisp-2.0.0a4.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
17
|
-
openforis_whisp-2.0.0a4.dist-info/RECORD,,
|