openforis-whisp 0.1.0a1__py3-none-any.whl → 0.1.0a3__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.
@@ -29,6 +29,10 @@ try:
29
29
  except Exception as e:
30
30
  print("Error in default EE initialization:", e)
31
31
 
32
+ from opebforis_whisp.datasets import (
33
+ combine_datasets,
34
+ )
35
+
32
36
  from openforis_whisp.stats import (
33
37
  whisp_stats_ee_to_ee,
34
38
  whisp_stats_ee_to_df,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: openforis-whisp
3
- Version: 0.1.0a1
3
+ Version: 0.1.0a3
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
@@ -82,8 +82,8 @@ The Forest Data Partnership promotes this approach for forest and commodities mo
82
82
 
83
83
  1) Tree and forest cover (at the end of 2020);
84
84
  2) Commodities (i.e., crop plantations and other agricultural uses at the end of 2020);
85
- 3) Disturbances **before 2020** (i.e., degredation or deforestation until 2020-12-31);
86
- 4) Disturbances **after 2020** (i.e., degredation or deforestation from 2021-01-01 onward).
85
+ 3) Disturbances **before 2020** (i.e., degradation or deforestation until 2020-12-31);
86
+ 4) Disturbances **after 2020** (i.e., degradation or deforestation from 2021-01-01 onward).
87
87
 
88
88
  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).
89
89
  Whisp checks the plots provided by the user by running zonal statistics on them to answer the following questions:
@@ -93,35 +93,27 @@ There are multiple datasets for each category. Find the full current [list of da
93
93
  3) Were there disturbances until 2020-12-31?
94
94
  4) Were there disturbances after 2020-12-31 / starting 2021-01-01?
95
95
 
96
- If no treecover dataset indicates any tree cover for a plot by the end of 2020, **Whisp will deem the deforestation risk as low.**
96
+ If no treecover dataset indicates any tree cover for a plot by the end of 2020, **Whisp will categorize the deforestation risk as low.**
97
97
 
98
- 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 deem the deforestation risk as low.**
98
+ 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.**
99
99
 
100
- If treecover datasets indicate tree cover on a plot by late 2020, no commodity datasets indicate agricultural use, but a disturbance datasets indicates disturbances before the end of 2020, **Whisp will deem the deforestation risk as <u>low</u>.** Such deforestation has happened before the EUDR cutoff date and therefore does not count as high risk for the EUDR.
100
+ 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 the EUDR cutoff date and is therefore not considered high risk for the EUDR.
101
101
 
102
- 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 degredation or deforestation have been reported in a disturbance dataset after 2020-12-31. If they have, **Whisp will deem the deforestation risk as <u>high</u>.** <br>
102
+ 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>
103
103
  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.
104
104
 
105
105
 
106
106
  *The Whisp algorithm visualized:*
107
- ![Kopie von whisp_decision_tree_20240909](https://github.com/user-attachments/assets/6a49dac8-d3b0-4137-871e-37a879d0e173)
107
+ ![CoE_Graphic 5](https://github.com/user-attachments/assets/007b5f50-3939-4707-95fa-98be4d56745f)
108
108
 
109
- --------------------------------------------------------------------------------
110
109
 
111
- ![whisp convergence of proof](images/pol_story_agu.gif)
110
+ # Run Whisp python package from a notebook
112
111
 
112
+ 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.
113
113
 
114
- ![whisp convergence of proof](images/pol_story_agu.gif)
114
+ A simple example of the package functionality can be seen in this [Colab Notebook](https://github.com/forestdatapartnership/whisp/blob/package-test-new-structure/notebooks/Colab_whisp_geojson_to_csv.ipynb)
115
115
 
116
- ## Run Whisp package using Python Notebooks
117
-
118
- For most users we suggest using the Whisp App to porcess their plots.
119
-
120
- For bespoke analyses using or implemetation in a python workflow you can sue the python package directly.
121
-
122
- See example [Colab Notebook](https://github.com/forestdatapartnership/whisp/blob/package-test-new-structure/notebooks/Colab_whisp_geojson_to_csv.ipynb)
123
-
124
- # Requirements
116
+ ## Requirements for running the package
125
117
 
126
118
  - A Google Earth Engine (GEE) account.
127
119
  - A registered cloud GEE project.
@@ -129,88 +121,30 @@ See example [Colab Notebook](https://github.com/forestdatapartnership/whisp/blob
129
121
 
130
122
  More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
131
123
 
132
- # Python package installation
133
-
134
- ...
135
- pip install openforis-whisp
124
+ ## Python package installation
136
125
 
137
- import openforis_whisp as whisp
138
- ...
126
+ The Whisp package is available on pip
127
+ https://pypi.org/project/openforis-whisp/
139
128
 
140
- If running the package locally we recommend using a [virtual environment](https://docs.python.org/3/library/venv.html) to keep your main python installation clean.
141
129
 
130
+ It can be installed with one line of code:
142
131
 
143
- The package relies upon the earth engine api being setup correctly using a registered cloud project
144
-
145
- # Earth Engine project name
146
- gee_project_name="my-ee-project"
132
+ ```
133
+ pip install -pre openforis-whisp
134
+ ```
147
135
 
148
- Where you must replace the GEE project in the
149
- ee.Initialize(project=gee_project_name)
136
+ If running locally we recommend a [virtual environment](https://docs.python.org/3/library/venv.html) to keep your main python installation clean.
150
137
 
151
- Note: this should be a registered cloud project. If unsure of this check pic here: https://developers.google.com/earth-engine/cloud/assets
138
+ The package relies upon the google earth engine api being setup correctly using a registered cloud project.
152
139
 
153
140
  More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
154
141
 
155
142
 
156
143
  ## How to add data layers to Whisp
157
-
158
- There are two main approaches: to request a layer be incorporated into the core Whisp inputs, or to add in your own data directly to complement the core ones in Whisp
159
-
160
- ### Requesting a dataset addition
161
- If you think a particular dataset has wide applicability for Whisp users, you can request it be added to the main Whisp repository by logging as an issue in Github [here] (https://github.com/forestdatapartnership/whisp/issues/). Before requesting consider: 1) is the resolution high enough for plot level analysis (e.g. 30m or 10m resolution), 2) is there an indication of data quality (e.g. accuracy assessment detailed in a scientific publication) and 3) is there relevant metadata available.
162
-
163
- ### Adding your own dataset for a bespoke Whisp analysis (using the Python Notebooks)
164
- Adding your To add other datasets, such as that are specific to your circumstances, or can’t be shared directly in GEE, follow the steps and guidance below.
165
-
166
- 1) Edit the datasets.py and add in a function to make a binary GEE image (i.e., where values are either 0 or 1*). Make sure the function name ends with "_prep", as only functions with this suffix are used.
167
- 2) Choose a name to represent the data layer in the final CSV output. Place in speech brackets in the .rename() section at the end of the function. See examples elsewhere in the functions in this script.
168
- 3) Edit parameters/lookup_gee_datasets.csv to include the chosen dataset name in a new row. Make sure other relevant columns are filled in.
169
-
170
- The above assumes a single band image that is being included, which results in a single column being added.
171
- If you have multiband images to add and want each band to be a layer in Whisp, make sure each band is named.
172
- Make sure to add all the bands to the lookup CSV (see Step 3), else they won’t appear in the output.
173
-
174
- How to fill out the columns parameters/lookup_gee_datasets.csv
175
- a. name: the name for the dataset column. NB must be exactly the same as the name of the image band in step 1.
176
- b. order: choose a number for where you want the dataset column placed in the CSV output.
177
- c. theme: a word denoting the dataset Theme. Currently there are five themes where i to iv correspond to:
178
- i. treecover: for forest or treecover at the end of 2020
179
- ii. commodities: representing commodities in 2020 (typically ones that tree cover might be confused with in remote sensing products).
180
- iii. disturbance_before: forest/tree cover disturbance before the end of 2020
181
- iv. disturbance_after: forest/tree cover disturbance after the end of 2020
182
- v. ancillary: other relevant layers, such as representing protected areas or areas of importance for biodiversity.
183
- d. use_for_risk: if 1 is added here this dataset is included in the risk calculations. The type of risk indicator it will contribute to is automatically governed by the “theme” column.
184
- NB if there is in a 1 in the "exclude_from_output" column this over-rules all of the above and the dataset is ignored. There are functions (in the modules/risk.py), to create lists for each of the 4 indicators from the lookup csv. These are used in the "whisp_risk" function for creating default columns to include in the final overall risk column.
185
- e. exclude_from_output: removes the column from the formatted final table (to remove input code out the function in the datasets.py)
186
- f. col_type:
187
- - choose 'float32' (most )
188
- - exceptions are 'bool' for showing True/False, where values >0 gives True.
189
- e. is nullable: set to 1
190
- f. is required: set to 0
191
- g. corresponding variable: the name of the function for creating the dataset in datasets.py (should end with "_prep")
192
-
193
-
194
- ### Tips for preparing and adding in your data
195
- • It’s sometimes easier to do initial checks in JavaScript and check all looks ok on the map in Code Editor, and then convert the code into Python. Tools that can help convert include AI interfaces such as ChatGPT, or [geemap] (https://giswqs.medium.com/15-converting-earth-engine-javascripts-to-python-code-with-just-a-few-mouse-clicks-6aa02b1268e1/).
196
- • Check your data: Python functions will still need sense checking and putting on a map is one way to do this using functions in [geemap] (https://geemap.org/notebooks/09_plotting/)
197
- • A binary input image is expected, but non-integer values are allowed if they range between 0 and 1. This is most appropriate for datasets that have proportion of coverage in a pixel (e.g., a value of 0.5 would represent having half the pixel covered).
198
- • If you are adding timeseries data, when creating the function you can use loops/mapping to compile a multiband input and to name each band accordingly.
199
-
200
- ## Key files
201
-
202
- # Parameters:
203
- - `lookup_gee_datasets.csv` contains the list of input datasets, the order they will be displayed, which ones are to be excluded from the current analysis, and which ones are shown as flags (i.e., shown as presence or absence instead of figures).
204
-
205
- ### src code
206
-
207
- Main Whisp analysis functions are found in the following files:
208
- - `datasets.py` functions for compiling GEE datasets into a single multiband image ready for input into the whisp analysis
209
- - `stats.py` functions to run Whisp analysis for each GEE dataset, providing results for coverage of each plot as an area in hectares
210
- -`risk.py` functions for estimating risk of deforestation.
144
+ There are two main approaches: to request a layer be incorporated into the core Whisp inputs, or to add in your own data directly to complement the core ones in Whisp. Currently the latter approach is under revision since moving to implementation in a python package. In the meantime please contact us through the issues page if this is functionality is useful to you.
211
145
 
212
146
  ## Contributing to the Whisp code base
213
- Contributions to the Whisp code in GitHub are welcome. They can be made by forking the repository making and pushing the required changes, then making a pull request to the Whisp repository. After briefly reviewing the request, we can make a branch for which to make a new pull request to. If in doubt get in contact first or log as an issue [here] (https://github.com/forestdatapartnership/whisp/issues/).
147
+ Contributions to the Whisp code in GitHub are welcome. They can be made by forking the repository making and pushing the required changes, then making a pull request to the Whisp repository. After briefly reviewing the request, we can make a branch for which to make a new pull request to. If in doubt get in contact first or log as an issue [here](https://github.com/forestdatapartnership/whisp/issues/).
214
148
 
215
149
  Install the package in editable mode with the additional dependencies required for testing and running pre-commit hooks:
216
150
  ```
@@ -226,5 +160,5 @@ pre-commit install
226
160
 
227
161
  You should be able to run the Pytest suite by simple running the `pytest` command from the repo's root folder.
228
162
 
229
- Please read the ![contributing guidelines](contributing_guidelines.md) for good practice recommendations.
163
+ Please read the [contributing guidelines](contributing_guidelines.md) for good practice recommendations.
230
164
 
@@ -1,4 +1,4 @@
1
- openforis_whisp/__init__.py,sha256=_7bgVQ8q9X9WeFpnzqN0uSD-TgM99B6G2DPWXROtf78,2301
1
+ openforis_whisp/__init__.py,sha256=TISKkIHIkWHIcXgxesFp4kS3NvcTc_I6B6RBYeLn6po,2373
2
2
  openforis_whisp/data_conversion.py,sha256=96en23_ysP7OfOJNGBssDyaX8seuzYGUarqdgnbI4SU,10961
3
3
  openforis_whisp/datasets.py,sha256=J-gThvw_4ZA6HyQXFHY2C1hHUzPN4tX-Ap_EbL3c-N0,23322
4
4
  openforis_whisp/logger.py,sha256=bcKu82a3njNIBiRghDcO_cC-SOK62cYAYuTaSWq7s9I,1354
@@ -11,7 +11,7 @@ openforis_whisp/reformat.py,sha256=_ByLR5bu_gPecH6W4jxymkcIN5Hph3bRIuRfjZByNBU,1
11
11
  openforis_whisp/risk.py,sha256=qgrBnioYS_vMPWs_rXFR5k_TacxBACHbeYmPhBmqMrM,13367
12
12
  openforis_whisp/stats.py,sha256=Y-IfazrTA_O5wQ8YE0GypXQYopp1V-ym_jPLwtNCw4M,26405
13
13
  openforis_whisp/utils.py,sha256=hpeY9aA3BND2m9c15PZ6_nClemsfiVNUEzA4pQXfztA,5330
14
- openforis_whisp-0.1.0a1.dist-info/LICENSE,sha256=nqyqICO95iw_iwzP1t_IIAf7ZX3DPbL_M9WyQfh2q1k,1085
15
- openforis_whisp-0.1.0a1.dist-info/METADATA,sha256=irr0deDjHjv6Dd1Z0LecKaR73dlfG8vnqe6kp5Zikg8,15647
16
- openforis_whisp-0.1.0a1.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
17
- openforis_whisp-0.1.0a1.dist-info/RECORD,,
14
+ openforis_whisp-0.1.0a3.dist-info/LICENSE,sha256=nqyqICO95iw_iwzP1t_IIAf7ZX3DPbL_M9WyQfh2q1k,1085
15
+ openforis_whisp-0.1.0a3.dist-info/METADATA,sha256=dPsiylilPt8t2TDjVSMe7lKrdW7wubcU0KV--6fPtEw,10364
16
+ openforis_whisp-0.1.0a3.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
17
+ openforis_whisp-0.1.0a3.dist-info/RECORD,,