openforis-whisp 2.0.0a4__tar.gz → 2.0.0a6__tar.gz

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.
Files changed (17) hide show
  1. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/LICENSE +21 -21
  2. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/PKG-INFO +37 -46
  3. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/README.md +36 -45
  4. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/pyproject.toml +85 -85
  5. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/__init__.py +75 -75
  6. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/data_conversion.py +493 -371
  7. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/datasets.py +1384 -1381
  8. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/logger.py +75 -75
  9. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/parameters/__init__.py +15 -15
  10. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/parameters/config_runtime.py +44 -44
  11. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/parameters/lookup_context_and_metadata.csv +13 -13
  12. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/parameters/lookup_gee_datasets.csv +1 -1
  13. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/pd_schemas.py +77 -77
  14. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/reformat.py +495 -495
  15. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/risk.py +771 -777
  16. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/stats.py +1134 -953
  17. {openforis_whisp-2.0.0a4 → openforis_whisp-2.0.0a6}/src/openforis_whisp/utils.py +154 -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.0a4
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
- Whisp checks the plots provided by the user by running zonal statistics on them to answer the following questions:
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
- If no treecover dataset indicates any tree cover for a plot by the end of 2020, **Whisp will categorize the deforestation risk as low.**
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
- ![CoE_Graphic 5](https://github.com/user-attachments/assets/007b5f50-3939-4707-95fa-98be4d56745f)
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 decision tree for the timber risk assessment slightly differs from the above. For more information see below.
145
-
146
-
154
+ *The Whisp algorithm for **Perennial Crops** visualized:*
155
+ ![CoE_Graphic 5](https://github.com/user-attachments/assets/007b5f50-3939-4707-95fa-98be4d56745f)
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
- ## Whisp datasets for timber <a name="whisp_datasets_timber"></a>
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
- 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).
164
- Whisp checks the plots provided by the user by running zonal statistics on them to answer the following questions:
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
- # Run Whisp python package from a notebook <a name="whisp_notebooks"></a>
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
- ## Requirements for running the package
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
- ## Python package installation
184
+ ### Python package installation
194
185
 
195
186
  The Whisp package is available on pip
196
187
  https://pypi.org/project/openforis-whisp/
@@ -40,8 +40,6 @@
40
40
 
41
41
 
42
42
  ## Whisp datasets <a name="whisp_datasets"></a>
43
- All output columns from Whisp are described in [this excel file](https://github.com/forestdatapartnership/whisp/blob/main/whisp_columns.xlsx)
44
-
45
43
  ***Whisp*** implements the convergence of evidence approach by providing a transparent and public processing flow using datasets covering the following categories:
46
44
 
47
45
  1) Tree and forest cover (at the end of 2020);
@@ -49,27 +47,39 @@
49
47
  3) Disturbances **before 2020** (i.e., degradation or deforestation until 2020-12-31);
50
48
  4) Disturbances **after 2020** (i.e., degradation or deforestation from 2021-01-01 onward).
51
49
 
50
+ Additional categories are specific for the timber commodity, considering a harvesting date in 2023:
51
+
52
+ 5) Primary forests in 2020;
53
+ 6) Naturally regenerating forests in 2020;
54
+ 7) Planted and plantation forests in 2020;
55
+ 8) Planted and plantation forests in 2023;
56
+ 9) Treecover in 2023;
57
+ 10) Commodities or croplands in 2023.
58
+ 11) Logging concessions;
59
+
52
60
  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).
53
- Whisp checks the plots provided by the user by running zonal statistics on them to answer the following questions:
61
+
62
+ ### Whisp risk assessment <a name="whisp_risk"></a>
63
+
64
+ Whisp checks the plots provided by the user by running zonal statistics on them to answer the following questions:
54
65
 
55
66
  1) Was there tree cover in 2020?
56
67
  2) Were there commodity plantations or other agricultural uses in 2020?
57
68
  3) Were there disturbances until 2020-12-31?
58
69
  4) Were there disturbances after 2020-12-31 / starting 2021-01-01?
59
70
 
60
- If no treecover dataset indicates any tree cover for a plot by the end of 2020, **Whisp will categorize the deforestation risk as low.**
61
-
62
- 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.**
63
-
64
- 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.
65
-
66
- 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>
67
- 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.
71
+ And specifically for the timber commodity, considering a harvesting date in 2023:
68
72
 
73
+ 5) Were there primary forests in 2020?
74
+ 6) Were there naturally regenerating forests in 2020?
75
+ 7) Were there planted and plantation forests in 2020?
76
+ 8) Were there planted and plantation forests in 2023?
77
+ 9) Was there treecover in 2023?
78
+ 10) Were there commodity plantations or other agricultural uses in 2023?
79
+ 11) Is it part of a logging concession?
69
80
 
70
- *The Whisp algorithm for **Perennial Crops** visualized:*
71
- ![CoE_Graphic 5](https://github.com/user-attachments/assets/007b5f50-3939-4707-95fa-98be4d56745f)
72
81
  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.
82
+ All output columns from Whisp are described in [this excel file](https://github.com/forestdatapartnership/whisp/blob/main/whisp_columns.xlsx)
73
83
 
74
84
  The **relevant risk assessment column depends on the commodity** in question:
75
85
 
@@ -104,47 +114,28 @@ The **relevant risk assessment column depends on the commodity** in question:
104
114
  </tr>
105
115
  </table>
106
116
 
107
- The decision tree for the timber risk assessment slightly differs from the above. For more information see below.
108
-
109
-
117
+ *The Whisp algorithm for **Perennial Crops** visualized:*
118
+ ![CoE_Graphic 5](https://github.com/user-attachments/assets/007b5f50-3939-4707-95fa-98be4d56745f)
119
+
120
+ If no treecover dataset indicates any tree cover for a plot by the end of 2020, **Whisp will categorize the deforestation risk as low.**
110
121
 
122
+ 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.**
111
123
 
112
- ## Whisp datasets for timber <a name="whisp_datasets_timber"></a>
113
- ***Whisp*** implements the convergence of evidence approach by providing a transparent and public processing flow using datasets covering the following categories:
114
- 1) Tree and forest cover (at the end of 2020);
115
- 2) Commodities (i.e., crop plantations and other agricultural uses at the end of 2020);
116
- 3) Disturbances **before 2020** (i.e., degradation or deforestation until 2020-12-31);
117
- 4) Disturbances **after 2020** (i.e., degradation or deforestation from 2021-01-01 onward).
118
- 5) Primary forests in 2020;
119
- 6) Naturally regenerating forests in 2020;
120
- 7) Planted and plantation forests in 2020;
121
- 8) Planted and plantation forests in 2023;
122
- 9) Treecover in 2023;
123
- 10) Commodities or croplands in 2023.
124
- 11) Logging concessions;
124
+ 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.
125
125
 
126
- 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).
127
- Whisp checks the plots provided by the user by running zonal statistics on them to answer the following questions:
126
+ 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>
127
+ 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.
128
128
 
129
- 1) Was there tree cover in 2020?
130
- 2) Were there commodity plantations or other agricultural uses in 2020?
131
- 3) Were there disturbances until 2020-12-31?
132
- 4) Were there disturbances after 2020-12-31 / starting 2021-01-01?
133
- 5) Were there primary forests in 2020?
134
- 6) Were there naturally regenerating forests in 2020?
135
- 7) Were there planted and plantation forests in 2020?
136
- 8) Were there planted and plantation forests in 2023?
137
- 9) Was there treecover in 2023?
138
- 10) Were there commodity plantations or other agricultural uses in 2023?
139
- 11) Were there logging concessions?
140
129
 
141
- # Run Whisp python package from a notebook <a name="whisp_notebooks"></a>
130
+ ## Run Whisp python package from a notebook <a name="whisp_notebooks"></a>
142
131
 
143
132
  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.
144
133
 
145
134
  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)
146
135
 
147
- ## Requirements for running the package
136
+ 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)
137
+
138
+ ### Requirements for running the package
148
139
 
149
140
  - A Google Earth Engine (GEE) account.
150
141
  - A registered cloud GEE project.
@@ -153,7 +144,7 @@ The **relevant risk assessment column depends on the commodity** in question:
153
144
  More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
154
145
 
155
146
 
156
- ## Python package installation
147
+ ### Python package installation
157
148
 
158
149
  The Whisp package is available on pip
159
150
  https://pypi.org/project/openforis-whisp/
@@ -1,85 +1,85 @@
1
- [build-system]
2
- requires = ["poetry-core>=1.0.0"]
3
- build-backend = "poetry.core.masonry.api"
4
-
5
- [tool.poetry]
6
- name = "openforis-whisp"
7
- version = "2.0.0a4"
8
- description = "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."
9
- repository = "https://github.com/forestdatapartnership/whisp"
10
- authors = ["Andy Arnell <and.arnell@fao.org>"]
11
- readme = "README.md"
12
- license = "MIT"
13
- keywords = ["whisp", "geospatial", "data-processing"]
14
- classifiers = [
15
- "Development Status :: 3 - Alpha",
16
- "Programming Language :: Python :: 3.10",
17
- "License :: OSI Approved :: MIT License",
18
- "Intended Audience :: Developers",
19
- "Intended Audience :: Science/Research",
20
- "Topic :: Software Development :: Libraries :: Python Modules"
21
- ]
22
-
23
- [tool.poetry.urls]
24
- "Documentation" = "https://github.com/forestdatapartnership/whisp#readme"
25
- "Development Branch" = "https://github.com/forestdatapartnership/whisp/tree/main"
26
- "Issues" = "https://github.com/forestdatapartnership/whisp/issues"
27
-
28
- [tool.poetry.dependencies]
29
- python = ">=3.10"
30
- earthengine-api = "*"
31
- numpy = ">=1.21.0,<3.0.0" # Updated version constraint
32
- pandas = ">=1.3.0,<3.0.0"
33
- pandera = {extras = ["io"], version = ">=0.22.1,<1.0.0"}
34
- country_converter = ">=0.7,<2.0.0"
35
- geojson = ">=2.5.0,<3.0.0"
36
- python-dotenv = ">=1.0.1,<2.0.0"
37
- pydantic-core = ">=2.14.0,<3.0.0" # Updated version constraint
38
- rsa = ">=4.2,<5.0.0" # Updated version constraint
39
- ipykernel = ">=6.17.1,<7.0.0" # Compatible with Colab
40
- shapely = "^2.0.2"
41
- geopandas = "^1.0.1"
42
-
43
- [tool.poetry.group.dev.dependencies]
44
- pytest = ">=6.2.5,<7.0.0"
45
- pre-commit = ">=2.15.0,<3.0.0"
46
- ruff = ">=0.0.1,<1.0.0"
47
-
48
- [tool.setuptools]
49
- package-dir = {"" = "src"}
50
- include-package-data = true
51
-
52
- [tool.setuptools.packages.find]
53
- where = ["src"]
54
-
55
- [tool.setuptools.package-data]
56
- "whisp.parameters" = ["lookup_gee_datasets.csv", "lookup_context_and_metadata.csv"]
57
-
58
- [tool.pytest.ini_options]
59
- log_cli = true
60
- log_cli_level = "DEBUG"
61
-
62
- [tool.ruff]
63
- fix = true
64
- select = [
65
- "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "N", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
66
- "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
67
- ]
68
- ignore = [
69
- "A003", "ANN002", "ANN003", "ANN101", "ANN102", "ANN401", "N805", "N818", "PLR0913", "RET504", "RET505"
70
- ]
71
- fixable = [
72
- "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
73
- "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
74
- ]
75
- unfixable = []
76
-
77
- exclude = [
78
- ".bzr", ".direnv",
79
- ]
80
-
81
- line-length = 120
82
- dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
83
-
84
- [tool.ruff.mccabe]
85
- max-complexity = 10
1
+ [build-system]
2
+ requires = ["poetry-core>=1.0.0"]
3
+ build-backend = "poetry.core.masonry.api"
4
+
5
+ [tool.poetry]
6
+ name = "openforis-whisp"
7
+ version = "2.0.0a6"
8
+ description = "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."
9
+ repository = "https://github.com/forestdatapartnership/whisp"
10
+ authors = ["Andy Arnell <and.arnell@fao.org>"]
11
+ readme = "README.md"
12
+ license = "MIT"
13
+ keywords = ["whisp", "geospatial", "data-processing"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Programming Language :: Python :: 3.10",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Intended Audience :: Developers",
19
+ "Intended Audience :: Science/Research",
20
+ "Topic :: Software Development :: Libraries :: Python Modules"
21
+ ]
22
+
23
+ [tool.poetry.urls]
24
+ "Documentation" = "https://github.com/forestdatapartnership/whisp#readme"
25
+ "Development Branch" = "https://github.com/forestdatapartnership/whisp/tree/main"
26
+ "Issues" = "https://github.com/forestdatapartnership/whisp/issues"
27
+
28
+ [tool.poetry.dependencies]
29
+ python = ">=3.10"
30
+ earthengine-api = "*"
31
+ numpy = ">=1.21.0,<3.0.0" # Updated version constraint
32
+ pandas = ">=1.3.0,<3.0.0"
33
+ pandera = {extras = ["io"], version = ">=0.22.1,<1.0.0"}
34
+ country_converter = ">=0.7,<2.0.0"
35
+ geojson = ">=2.5.0,<3.0.0"
36
+ python-dotenv = ">=1.0.1,<2.0.0"
37
+ pydantic-core = ">=2.14.0,<3.0.0" # Updated version constraint
38
+ rsa = ">=4.2,<5.0.0" # Updated version constraint
39
+ ipykernel = ">=6.17.1,<7.0.0" # Compatible with Colab
40
+ shapely = "^2.0.2"
41
+ geopandas = "^1.0.1"
42
+
43
+ [tool.poetry.group.dev.dependencies]
44
+ pytest = ">=6.2.5,<7.0.0"
45
+ pre-commit = ">=2.15.0,<3.0.0"
46
+ ruff = ">=0.0.1,<1.0.0"
47
+
48
+ [tool.setuptools]
49
+ package-dir = {"" = "src"}
50
+ include-package-data = true
51
+
52
+ [tool.setuptools.packages.find]
53
+ where = ["src"]
54
+
55
+ [tool.setuptools.package-data]
56
+ "whisp.parameters" = ["lookup_gee_datasets.csv", "lookup_context_and_metadata.csv"]
57
+
58
+ [tool.pytest.ini_options]
59
+ log_cli = true
60
+ log_cli_level = "DEBUG"
61
+
62
+ [tool.ruff]
63
+ fix = true
64
+ select = [
65
+ "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "N", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
66
+ "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
67
+ ]
68
+ ignore = [
69
+ "A003", "ANN002", "ANN003", "ANN101", "ANN102", "ANN401", "N805", "N818", "PLR0913", "RET504", "RET505"
70
+ ]
71
+ fixable = [
72
+ "A", "ANN", "ARG", "B", "C", "COM", "C90", "E", "ERA", "F", "I", "PGH", "PL", "PLE", "PLR", "PLW", "PT",
73
+ "PTH", "Q", "RET", "RUF", "SLF", "SIM", "TID", "TRY", "UP", "W", "YTT"
74
+ ]
75
+ unfixable = []
76
+
77
+ exclude = [
78
+ ".bzr", ".direnv",
79
+ ]
80
+
81
+ line-length = 120
82
+ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
83
+
84
+ [tool.ruff.mccabe]
85
+ max-complexity = 10
@@ -1,75 +1,75 @@
1
- import ee
2
- from google.oauth2 import service_account
3
-
4
-
5
- def initialize_ee(credentials_path=None):
6
- """Initializes Google Earth Engine using the provided path or defaults to normal if no path is given."""
7
- try:
8
- if not ee.data._initialized:
9
- print(credentials_path)
10
- if credentials_path:
11
- credentials = service_account.Credentials.from_service_account_file(
12
- credentials_path,
13
- scopes=["https://www.googleapis.com/auth/earthengine"],
14
- )
15
- ee.Initialize(credentials)
16
- print("EE initialized with credentials from:", credentials_path)
17
- else:
18
- ee.Initialize()
19
- print("EE initialized with default credentials.")
20
- except Exception as e:
21
- print("Error initializing EE:", e)
22
-
23
-
24
- # Default to normal initialize if nobody calls whisp.initialize_ee.
25
- try:
26
- if not ee.data._initialized:
27
- ee.Initialize()
28
- print("EE auto-initialized with default credentials.")
29
- except Exception as e:
30
- print("Error in default EE initialization:", e)
31
-
32
- from openforis_whisp.datasets import (
33
- combine_datasets,
34
- )
35
-
36
- from openforis_whisp.stats import (
37
- whisp_stats_ee_to_ee,
38
- whisp_stats_ee_to_df,
39
- whisp_stats_geojson_to_df,
40
- whisp_stats_geojson_to_ee,
41
- whisp_stats_geojson_to_geojson,
42
- whisp_stats_ee_to_drive,
43
- whisp_stats_geojson_to_drive,
44
- whisp_formatted_stats_ee_to_df,
45
- whisp_formatted_stats_ee_to_geojson,
46
- whisp_formatted_stats_geojson_to_df,
47
- whisp_formatted_stats_geojson_to_geojson,
48
- convert_iso3_to_iso2,
49
- )
50
-
51
- # temporary parameters to be removed once isio3 to iso2 conversion server side is implemented
52
- from openforis_whisp.parameters.config_runtime import (
53
- iso3_country_column,
54
- iso2_country_column,
55
- )
56
-
57
- from openforis_whisp.reformat import (
58
- validate_dataframe_using_lookups,
59
- validate_dataframe,
60
- create_schema_from_dataframe,
61
- load_schema_if_any_file_changed,
62
- # log_missing_columns,
63
- )
64
-
65
- from openforis_whisp.data_conversion import (
66
- convert_ee_to_df,
67
- convert_geojson_to_ee,
68
- convert_df_to_geojson,
69
- convert_csv_to_geojson,
70
- convert_ee_to_geojson,
71
- )
72
-
73
- from openforis_whisp.risk import whisp_risk, detect_unit_type
74
-
75
- from openforis_whisp.utils import get_example_data_path
1
+ import ee
2
+ from google.oauth2 import service_account
3
+
4
+
5
+ def initialize_ee(credentials_path=None):
6
+ """Initializes Google Earth Engine using the provided path or defaults to normal if no path is given."""
7
+ try:
8
+ if not ee.data._initialized:
9
+ print(credentials_path)
10
+ if credentials_path:
11
+ credentials = service_account.Credentials.from_service_account_file(
12
+ credentials_path,
13
+ scopes=["https://www.googleapis.com/auth/earthengine"],
14
+ )
15
+ ee.Initialize(credentials)
16
+ print("EE initialized with credentials from:", credentials_path)
17
+ else:
18
+ ee.Initialize()
19
+ print("EE initialized with default credentials.")
20
+ except Exception as e:
21
+ print("Error initializing EE:", e)
22
+
23
+
24
+ # Default to normal initialize if nobody calls whisp.initialize_ee.
25
+ try:
26
+ if not ee.data._initialized:
27
+ ee.Initialize()
28
+ print("EE auto-initialized with default credentials.")
29
+ except Exception as e:
30
+ print("Error in default EE initialization:", e)
31
+
32
+ from openforis_whisp.datasets import (
33
+ combine_datasets,
34
+ )
35
+
36
+ from openforis_whisp.stats import (
37
+ whisp_stats_ee_to_ee,
38
+ whisp_stats_ee_to_df,
39
+ whisp_stats_geojson_to_df,
40
+ whisp_stats_geojson_to_ee,
41
+ whisp_stats_geojson_to_geojson,
42
+ whisp_stats_ee_to_drive,
43
+ whisp_stats_geojson_to_drive,
44
+ whisp_formatted_stats_ee_to_df,
45
+ whisp_formatted_stats_ee_to_geojson,
46
+ whisp_formatted_stats_geojson_to_df,
47
+ whisp_formatted_stats_geojson_to_geojson,
48
+ convert_iso3_to_iso2,
49
+ )
50
+
51
+ # temporary parameters to be removed once isio3 to iso2 conversion server side is implemented
52
+ from openforis_whisp.parameters.config_runtime import (
53
+ iso3_country_column,
54
+ iso2_country_column,
55
+ )
56
+
57
+ from openforis_whisp.reformat import (
58
+ validate_dataframe_using_lookups,
59
+ validate_dataframe,
60
+ create_schema_from_dataframe,
61
+ load_schema_if_any_file_changed,
62
+ # log_missing_columns,
63
+ )
64
+
65
+ from openforis_whisp.data_conversion import (
66
+ convert_ee_to_df,
67
+ convert_geojson_to_ee,
68
+ convert_df_to_geojson,
69
+ convert_csv_to_geojson,
70
+ convert_ee_to_geojson,
71
+ )
72
+
73
+ from openforis_whisp.risk import whisp_risk, detect_unit_type
74
+
75
+ from openforis_whisp.utils import get_example_data_path