openforis-whisp 0.0.1__tar.gz → 0.1.0a0__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.
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/PKG-INFO +59 -127
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/README.md +54 -126
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/pyproject.toml +7 -1
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/LICENSE +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/__init__.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/data_conversion.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/datasets.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/logger.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/parameters/__init__.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/parameters/config_runtime.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/parameters/lookup_context_and_metadata.csv +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/parameters/lookup_gee_datasets.csv +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/pd_schemas.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/reformat.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/risk.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/stats.py +0 -0
- {openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: openforis-whisp
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.1.0a0
|
|
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
|
|
@@ -29,6 +29,10 @@ Requires-Dist: pydantic-core (>=2.14.0,<3.0.0)
|
|
|
29
29
|
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
|
30
30
|
Requires-Dist: rsa (>=4.2,<5.0.0)
|
|
31
31
|
Requires-Dist: shapely (>=2.0.2,<3.0.0)
|
|
32
|
+
Project-URL: Documentation, https://github.com/forestdatapartnership/whisp#readme
|
|
33
|
+
Project-URL: Development Branch, https://github.com/forestdatapartnership/whisp/tree/package-test-new-structure
|
|
34
|
+
Project-URL: Issues, https://github.com/forestdatapartnership/whisp/issues
|
|
35
|
+
Project-URL: Repository, https://github.com/forestdatapartnership/whisp
|
|
32
36
|
Description-Content-Type: text/markdown
|
|
33
37
|
|
|
34
38
|
whisp
|
|
@@ -38,7 +42,6 @@ whisp
|
|
|
38
42
|
[](https://doi.org/10.4060/cd0957en)
|
|
39
43
|
|
|
40
44
|
|
|
41
|
-
|
|
42
45
|

|
|
43
46
|
|
|
44
47
|
## Convergence of Evidence <a name="whisp_coe"></a>
|
|
@@ -67,13 +70,12 @@ The Forest Data Partnership promotes this approach for forest and commodities mo
|
|
|
67
70
|
***Whisp*** can currently be used directly or implemented in your own code through three different pathways:
|
|
68
71
|
|
|
69
72
|
|
|
70
|
-
1. The Whisp App with its simple interface can be used [right here](https://whisp.openforis.org/) or called from other software by [API](https://whisp.openforis.org/documentation/api-guide). The Whisp App currently supports the processing of up to
|
|
73
|
+
1. The Whisp App with its simple interface can be used [right here](https://whisp.openforis.org/) or called from other software by [API](https://whisp.openforis.org/documentation/api-guide). The Whisp App currently supports the processing of up to 1000 geometries per job. The original JS & Python code behind the Whisp App and API can be found [here](https://github.com/forestdatapartnership/whisp-app).
|
|
71
74
|
|
|
72
75
|
2. [Whisp in Earthmap](https://whisp.earthmap.org/?aoi=WHISP&boundary=plot1&layers=%7B%22CocoaETH%22%3A%7B%22opacity%22%3A1%7D%2C%22JRCForestMask%22%3A%7B%22opacity%22%3A1%7D%2C%22planet_rgb%22%3A%7B%22opacity%22%3A1%2C%22date%22%3A%222020-12%22%7D%7D&map=%7B%22center%22%3A%7B%22lat%22%3A7%2C%22lng%22%3A4%7D%2C%22zoom%22%3A3%2C%22mapType%22%3A%22satellite%22%7D&statisticsOpen=true) supports the visualization of geometries on actual maps with the possibility to toggle different relevant map products around tree cover, commodities and deforestation. It is practical for demonstration purposes and spot checks of single geometries but not recommended for larger datasets.
|
|
73
76
|
|
|
74
|
-
3. Datasets of any size, especially when holding more than
|
|
77
|
+
3. Datasets of any size, especially when holding more than 1000 geometries, can be "whisped" through the [python package on pip](https://pypi.org/project/openforis-whisp/). See [Colab notebook] (https://github.com/forestdatapartnership/whisp/blob/package-test-new-structure/notebooks/Colab_whisp_geojson_to_csv.ipynb) for example implementation with a geojson input. For the detailed procedure please go to the section [Whisp notebooks](#whisp_notebooks).
|
|
75
78
|
|
|
76
|
-
<br>
|
|
77
79
|
|
|
78
80
|
## Whisp datasets <a name="whisp_datasets"></a>
|
|
79
81
|
***Whisp*** implements the convergence of evidence approach by providing a transparent and public processing flow using datasets covering the following categories:
|
|
@@ -108,143 +110,45 @@ However, under the same circumstances but with <u>no</u> disturbances reported a
|
|
|
108
110
|
|
|
109
111
|

|
|
110
112
|
|
|
111
|
-
# Requirements
|
|
112
|
-
|
|
113
|
-
- A Google Earth Engine (GEE) account.
|
|
114
|
-
- A registered cloud GEE project.
|
|
115
|
-
- Some experience in Python or a similar language.
|
|
116
|
-
|
|
117
|
-
# Setup
|
|
118
|
-
Consider creating a virtual environment to keep your main python installation clean.
|
|
119
|
-
This can be done through this command line
|
|
120
|
-
```
|
|
121
|
-
python -m venv env
|
|
122
|
-
```
|
|
123
|
-
More info on virtual environments here: https://docs.python.org/3/library/venv.html
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
If installing from GitHUb
|
|
127
|
-
Clone the Whisp repo and install the package:
|
|
128
|
-
```
|
|
129
|
-
git clone https://github.com/forestdatapartnership/whisp.git
|
|
130
|
-
cd whisp/
|
|
131
|
-
pip install .
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
Create a `.env` file with the required information for Earth Engine login (you may copy and edit the `.env.template`
|
|
135
|
-
file found in the root directory). The file must contain the following environment variables:
|
|
136
|
-
```
|
|
137
|
-
# Earth Engine project name
|
|
138
|
-
PROJECT="my-ee-project"
|
|
139
|
-
```
|
|
140
|
-
Where you must replace the GEE project name by your own.
|
|
141
|
-
|
|
142
|
-
Note: this should be a registered cloud project. If unsure of this check pic here: https://developers.google.com/earth-engine/cloud/assets
|
|
143
|
-
|
|
144
113
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
Install the package in editable mode with the additional dependencies required for testing and running pre-commit hooks:
|
|
148
|
-
```
|
|
149
|
-
git clone https://github.com/forestdatapartnership/whisp.git
|
|
150
|
-
cd whisp/
|
|
151
|
-
pip install -e .[dev]
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Setup the pre-commit hooks:
|
|
155
|
-
```
|
|
156
|
-
pre-commit install
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
You should be able to run the Pytest suite by simple running the `pytest` command from the repo's root folder.
|
|
161
|
-
|
|
162
|
-
Please read the  for good practice recommendations.
|
|
114
|
+

|
|
163
115
|
|
|
116
|
+
## Run Whisp package using Python Notebooks
|
|
164
117
|
|
|
165
|
-
|
|
166
|
-
***whisp*** can be implemented through at least three pathways
|
|
118
|
+
For most users we suggest using the Whisp App to porcess their plots.
|
|
167
119
|
|
|
168
|
-
|
|
120
|
+
For bespoke analyses using or implemetation in a python workflow you can sue the python package directly.
|
|
169
121
|
|
|
170
|
-
|
|
122
|
+
See example [Colab notebook] (https://github.com/forestdatapartnership/whisp/blob/package-test-new-structure/notebooks/Colab_whisp_geojson_to_csv.ipynb)
|
|
171
123
|
|
|
172
|
-
|
|
124
|
+
# Requirements
|
|
173
125
|
|
|
174
|
-
|
|
126
|
+
- A Google Earth Engine (GEE) account.
|
|
127
|
+
- A registered cloud GEE project.
|
|
128
|
+
- Some experience in Python or a similar language.
|
|
175
129
|
|
|
176
130
|
More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
|
|
177
131
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
The Python notebooks are currently set up to run in Sepal and to focus on polygon data provided by the user or geo_ids that allow the notebooks to access polygons stored and registered in the Asset Registry. NB: We value your feedback in terms of what input data we should support.
|
|
132
|
+
# Python package installation
|
|
181
133
|
|
|
182
|
-
|
|
134
|
+
pip install openforis-whisp
|
|
183
135
|
|
|
184
|
-
|
|
136
|
+
...
|
|
185
137
|
|
|
186
|
-
|
|
187
|
-
2. Open the notebook `whisp_geojson.ipynb` from inside the "notebooks" folder.
|
|
188
|
-
3. To run the notebook cells, press the Play icon, or use the Shift + Enter shortcut. For more info on Jupyter and controlling notebooks, see [here](https://jupyter.org/try-jupyter/lab/).
|
|
189
|
-
4. Once you have initialised and agreed to the Google Earth Engine access requirements, you can process a geojson file containing plot informations.
|
|
190
|
-
5. The outputs from the notebook can be set to where you want to store them.
|
|
191
|
-
6. Outputs from the process include a CSV file `whisp_output_table.csv`.
|
|
192
|
-
7. NB If the processing job is large this may take some time. IF the outputs fail to process due to memory or time out errors, you can use the alternative function 'whisp_stats_geojson_to_drive', that sends a csv outpout to your Google drive. We are developing functionality to upload the csv automatically. In the meantime manually downloading from Google Drive and saving the csv is required. You can then import the csv as a pandas dataframe and use the 'validate_dataframe_using_lookups' function to get the Whisp output format (i.e., using a set schema for a standardised output, useful for showing in Power Bi etc).
|
|
138
|
+
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.
|
|
193
139
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
### Output 1
|
|
198
|
-
|
|
199
|
-
- A CSV called `whisp_output_table.csv` contains results from the whisp processing.
|
|
200
|
-
|
|
201
|
-
### Output 2
|
|
202
|
-
|
|
203
|
-
- A CSV called `whisp_output_table_w_risk.csv` contains results from the whisp processing and risk indicators.
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
## Other Files
|
|
207
|
-
|
|
208
|
-
### Parameters Folder
|
|
209
|
-
|
|
210
|
-
A folder containing a series of Python scripts and a CSV. These files are used to define various parameters used in the analysis.
|
|
211
|
-
|
|
212
|
-
Key files include:
|
|
213
|
-
- `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 for area/percentage coverage of the plot).
|
|
214
|
-
- `config_runtime.py` contains parameters such as default file and column names. **WARNING: USERS SHOULD NOT EDIT PACKAGE CONFIG ; IF THEY WANT TO, THEY SHOULD INSTALL THE PACKAGE IN EDITABLE MODE IN ORDER TO BE ABLE TO MODIFY CONFIGS WITHOUT HAVING TO RE-INSTALL THE PACKGE EVERY TIME**
|
|
215
|
-
|
|
216
|
-
### src code
|
|
217
|
-
|
|
218
|
-
Various functions for the main Whisp analysis along with some for interacting with the AgStack Asset Registry.
|
|
219
|
-
|
|
220
|
-
Key files:
|
|
221
|
-
- `datasets.py` contains a series of functions related to the creation of a single multiband GEE image to be used in the Whisp summary statistics analysis.
|
|
222
|
-
- `stats.py` contains functions to run the Whisp analysis for each of the various datasets and to provide results for coverage of each plot as a percentage (or as an area in hectares).
|
|
223
|
-
|
|
224
|
-
## Setting Up Your System
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
### Setting Up SEPAL
|
|
228
|
-
|
|
229
|
-
SEPAL is closely linked to Google Earth Engine (GEE), a Google-powered Earth-observation cloud-computing platform, as it builds in many of its functionalities. Currently, you will need to have connected SEPAL and GEE accounts. SEPAL provides a stable processing environment and allows you to link up with your Google account saving time with permissions. Currently, we are supporting the use within SEPAL, but you can run the scripts outside of SEPAL if required, although this will require extra code to account for the various dependencies SEPAL already has built in.
|
|
230
|
-
|
|
231
|
-
1. Login to SEPAL.
|
|
232
|
-
2. Start an instance (see Terminal info) to provide you with free processing power.
|
|
233
|
-
3. If you don’t have SEPAL set up:
|
|
234
|
-
- To create a SEPAL account, please follow the registration steps described [here](https://docs.sepal.io/en/latest/setup/register.html) and then familiarize yourself with the tool by exploring its interface.
|
|
235
|
-
- To create a Google Earth Engine (GEE) account, please follow these steps and don’t forget to initialize the home folder.
|
|
236
|
-
|
|
237
|
-
### Setting Up the Whisp GitHub Repository
|
|
140
|
+
```
|
|
141
|
+
The package relies upon the earth engine api being setup correctly using a registered cloud project
|
|
238
142
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
143
|
+
# Earth Engine project name
|
|
144
|
+
gee_project_name="my-ee-project"
|
|
145
|
+
```
|
|
146
|
+
Where you must replace the GEE project in the
|
|
147
|
+
ee.Initialize(project=gee_project_name)
|
|
242
148
|
|
|
243
|
-
|
|
244
|
-
git clone https://github.com/forestdatapartnership/whisp.git
|
|
245
|
-
```
|
|
149
|
+
Note: this should be a registered cloud project. If unsure of this check pic here: https://developers.google.com/earth-engine/cloud/assets
|
|
246
150
|
|
|
247
|
-
|
|
151
|
+
More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
|
|
248
152
|
|
|
249
153
|
|
|
250
154
|
## How to add data layers to Whisp
|
|
@@ -252,12 +156,12 @@ SEPAL is closely linked to Google Earth Engine (GEE), a Google-powered Earth-obs
|
|
|
252
156
|
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
|
|
253
157
|
|
|
254
158
|
### Requesting a dataset addition
|
|
255
|
-
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/).
|
|
159
|
+
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.
|
|
256
160
|
|
|
257
161
|
### Adding your own dataset for a bespoke Whisp analysis (using the Python Notebooks)
|
|
258
162
|
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.
|
|
259
163
|
|
|
260
|
-
1) Edit
|
|
164
|
+
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.
|
|
261
165
|
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.
|
|
262
166
|
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.
|
|
263
167
|
|
|
@@ -291,6 +195,34 @@ g. corresponding variable: the name of the function for creating the dataset in
|
|
|
291
195
|
• 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).
|
|
292
196
|
• 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.
|
|
293
197
|
|
|
198
|
+
## Key files
|
|
199
|
+
|
|
200
|
+
# Parameters:
|
|
201
|
+
- `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).
|
|
202
|
+
|
|
203
|
+
### src code
|
|
204
|
+
|
|
205
|
+
Main Whisp analysis functions are found in the following files:
|
|
206
|
+
- `datasets.py` functions for compiling GEE datasets into a single multiband image ready for input into the whisp analysis
|
|
207
|
+
- `stats.py` functions to run Whisp analysis for each GEE dataset, providing results for coverage of each plot as an area in hectares
|
|
208
|
+
-`risk.py` functions for estimating risk of deforestation.
|
|
209
|
+
|
|
294
210
|
## Contributing to the Whisp code base
|
|
295
211
|
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/).
|
|
296
212
|
|
|
213
|
+
Install the package in editable mode with the additional dependencies required for testing and running pre-commit hooks:
|
|
214
|
+
```
|
|
215
|
+
git clone https://github.com/forestdatapartnership/whisp.git
|
|
216
|
+
cd whisp/
|
|
217
|
+
pip install -e .[dev]
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Setup the pre-commit hooks:
|
|
221
|
+
```
|
|
222
|
+
pre-commit install
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
You should be able to run the Pytest suite by simple running the `pytest` command from the repo's root folder.
|
|
226
|
+
|
|
227
|
+
Please read the  for good practice recommendations.
|
|
228
|
+
|
|
@@ -5,7 +5,6 @@ whisp
|
|
|
5
5
|
[](https://doi.org/10.4060/cd0957en)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|

|
|
10
9
|
|
|
11
10
|
## Convergence of Evidence <a name="whisp_coe"></a>
|
|
@@ -34,13 +33,12 @@ The Forest Data Partnership promotes this approach for forest and commodities mo
|
|
|
34
33
|
***Whisp*** can currently be used directly or implemented in your own code through three different pathways:
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
1. The Whisp App with its simple interface can be used [right here](https://whisp.openforis.org/) or called from other software by [API](https://whisp.openforis.org/documentation/api-guide). The Whisp App currently supports the processing of up to
|
|
36
|
+
1. The Whisp App with its simple interface can be used [right here](https://whisp.openforis.org/) or called from other software by [API](https://whisp.openforis.org/documentation/api-guide). The Whisp App currently supports the processing of up to 1000 geometries per job. The original JS & Python code behind the Whisp App and API can be found [here](https://github.com/forestdatapartnership/whisp-app).
|
|
38
37
|
|
|
39
38
|
2. [Whisp in Earthmap](https://whisp.earthmap.org/?aoi=WHISP&boundary=plot1&layers=%7B%22CocoaETH%22%3A%7B%22opacity%22%3A1%7D%2C%22JRCForestMask%22%3A%7B%22opacity%22%3A1%7D%2C%22planet_rgb%22%3A%7B%22opacity%22%3A1%2C%22date%22%3A%222020-12%22%7D%7D&map=%7B%22center%22%3A%7B%22lat%22%3A7%2C%22lng%22%3A4%7D%2C%22zoom%22%3A3%2C%22mapType%22%3A%22satellite%22%7D&statisticsOpen=true) supports the visualization of geometries on actual maps with the possibility to toggle different relevant map products around tree cover, commodities and deforestation. It is practical for demonstration purposes and spot checks of single geometries but not recommended for larger datasets.
|
|
40
39
|
|
|
41
|
-
3. Datasets of any size, especially when holding more than
|
|
40
|
+
3. Datasets of any size, especially when holding more than 1000 geometries, can be "whisped" through the [python package on pip](https://pypi.org/project/openforis-whisp/). See [Colab notebook] (https://github.com/forestdatapartnership/whisp/blob/package-test-new-structure/notebooks/Colab_whisp_geojson_to_csv.ipynb) for example implementation with a geojson input. For the detailed procedure please go to the section [Whisp notebooks](#whisp_notebooks).
|
|
42
41
|
|
|
43
|
-
<br>
|
|
44
42
|
|
|
45
43
|
## Whisp datasets <a name="whisp_datasets"></a>
|
|
46
44
|
***Whisp*** implements the convergence of evidence approach by providing a transparent and public processing flow using datasets covering the following categories:
|
|
@@ -75,143 +73,45 @@ However, under the same circumstances but with <u>no</u> disturbances reported a
|
|
|
75
73
|
|
|
76
74
|

|
|
77
75
|
|
|
78
|
-
# Requirements
|
|
79
|
-
|
|
80
|
-
- A Google Earth Engine (GEE) account.
|
|
81
|
-
- A registered cloud GEE project.
|
|
82
|
-
- Some experience in Python or a similar language.
|
|
83
|
-
|
|
84
|
-
# Setup
|
|
85
|
-
Consider creating a virtual environment to keep your main python installation clean.
|
|
86
|
-
This can be done through this command line
|
|
87
|
-
```
|
|
88
|
-
python -m venv env
|
|
89
|
-
```
|
|
90
|
-
More info on virtual environments here: https://docs.python.org/3/library/venv.html
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
If installing from GitHUb
|
|
94
|
-
Clone the Whisp repo and install the package:
|
|
95
|
-
```
|
|
96
|
-
git clone https://github.com/forestdatapartnership/whisp.git
|
|
97
|
-
cd whisp/
|
|
98
|
-
pip install .
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
Create a `.env` file with the required information for Earth Engine login (you may copy and edit the `.env.template`
|
|
102
|
-
file found in the root directory). The file must contain the following environment variables:
|
|
103
|
-
```
|
|
104
|
-
# Earth Engine project name
|
|
105
|
-
PROJECT="my-ee-project"
|
|
106
|
-
```
|
|
107
|
-
Where you must replace the GEE project name by your own.
|
|
108
|
-
|
|
109
|
-
Note: this should be a registered cloud project. If unsure of this check pic here: https://developers.google.com/earth-engine/cloud/assets
|
|
110
|
-
|
|
111
76
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
Install the package in editable mode with the additional dependencies required for testing and running pre-commit hooks:
|
|
115
|
-
```
|
|
116
|
-
git clone https://github.com/forestdatapartnership/whisp.git
|
|
117
|
-
cd whisp/
|
|
118
|
-
pip install -e .[dev]
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Setup the pre-commit hooks:
|
|
122
|
-
```
|
|
123
|
-
pre-commit install
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
You should be able to run the Pytest suite by simple running the `pytest` command from the repo's root folder.
|
|
128
|
-
|
|
129
|
-
Please read the  for good practice recommendations.
|
|
77
|
+

|
|
130
78
|
|
|
79
|
+
## Run Whisp package using Python Notebooks
|
|
131
80
|
|
|
132
|
-
|
|
133
|
-
***whisp*** can be implemented through at least three pathways
|
|
81
|
+
For most users we suggest using the Whisp App to porcess their plots.
|
|
134
82
|
|
|
135
|
-
|
|
83
|
+
For bespoke analyses using or implemetation in a python workflow you can sue the python package directly.
|
|
136
84
|
|
|
137
|
-
|
|
85
|
+
See example [Colab notebook] (https://github.com/forestdatapartnership/whisp/blob/package-test-new-structure/notebooks/Colab_whisp_geojson_to_csv.ipynb)
|
|
138
86
|
|
|
139
|
-
|
|
87
|
+
# Requirements
|
|
140
88
|
|
|
141
|
-
|
|
89
|
+
- A Google Earth Engine (GEE) account.
|
|
90
|
+
- A registered cloud GEE project.
|
|
91
|
+
- Some experience in Python or a similar language.
|
|
142
92
|
|
|
143
93
|
More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
|
|
144
94
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
The Python notebooks are currently set up to run in Sepal and to focus on polygon data provided by the user or geo_ids that allow the notebooks to access polygons stored and registered in the Asset Registry. NB: We value your feedback in terms of what input data we should support.
|
|
95
|
+
# Python package installation
|
|
148
96
|
|
|
149
|
-
|
|
97
|
+
pip install openforis-whisp
|
|
150
98
|
|
|
151
|
-
|
|
99
|
+
...
|
|
152
100
|
|
|
153
|
-
|
|
154
|
-
2. Open the notebook `whisp_geojson.ipynb` from inside the "notebooks" folder.
|
|
155
|
-
3. To run the notebook cells, press the Play icon, or use the Shift + Enter shortcut. For more info on Jupyter and controlling notebooks, see [here](https://jupyter.org/try-jupyter/lab/).
|
|
156
|
-
4. Once you have initialised and agreed to the Google Earth Engine access requirements, you can process a geojson file containing plot informations.
|
|
157
|
-
5. The outputs from the notebook can be set to where you want to store them.
|
|
158
|
-
6. Outputs from the process include a CSV file `whisp_output_table.csv`.
|
|
159
|
-
7. NB If the processing job is large this may take some time. IF the outputs fail to process due to memory or time out errors, you can use the alternative function 'whisp_stats_geojson_to_drive', that sends a csv outpout to your Google drive. We are developing functionality to upload the csv automatically. In the meantime manually downloading from Google Drive and saving the csv is required. You can then import the csv as a pandas dataframe and use the 'validate_dataframe_using_lookups' function to get the Whisp output format (i.e., using a set schema for a standardised output, useful for showing in Power Bi etc).
|
|
101
|
+
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.
|
|
160
102
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
### Output 1
|
|
165
|
-
|
|
166
|
-
- A CSV called `whisp_output_table.csv` contains results from the whisp processing.
|
|
167
|
-
|
|
168
|
-
### Output 2
|
|
169
|
-
|
|
170
|
-
- A CSV called `whisp_output_table_w_risk.csv` contains results from the whisp processing and risk indicators.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
## Other Files
|
|
174
|
-
|
|
175
|
-
### Parameters Folder
|
|
176
|
-
|
|
177
|
-
A folder containing a series of Python scripts and a CSV. These files are used to define various parameters used in the analysis.
|
|
178
|
-
|
|
179
|
-
Key files include:
|
|
180
|
-
- `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 for area/percentage coverage of the plot).
|
|
181
|
-
- `config_runtime.py` contains parameters such as default file and column names. **WARNING: USERS SHOULD NOT EDIT PACKAGE CONFIG ; IF THEY WANT TO, THEY SHOULD INSTALL THE PACKAGE IN EDITABLE MODE IN ORDER TO BE ABLE TO MODIFY CONFIGS WITHOUT HAVING TO RE-INSTALL THE PACKGE EVERY TIME**
|
|
182
|
-
|
|
183
|
-
### src code
|
|
184
|
-
|
|
185
|
-
Various functions for the main Whisp analysis along with some for interacting with the AgStack Asset Registry.
|
|
186
|
-
|
|
187
|
-
Key files:
|
|
188
|
-
- `datasets.py` contains a series of functions related to the creation of a single multiband GEE image to be used in the Whisp summary statistics analysis.
|
|
189
|
-
- `stats.py` contains functions to run the Whisp analysis for each of the various datasets and to provide results for coverage of each plot as a percentage (or as an area in hectares).
|
|
190
|
-
|
|
191
|
-
## Setting Up Your System
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
### Setting Up SEPAL
|
|
195
|
-
|
|
196
|
-
SEPAL is closely linked to Google Earth Engine (GEE), a Google-powered Earth-observation cloud-computing platform, as it builds in many of its functionalities. Currently, you will need to have connected SEPAL and GEE accounts. SEPAL provides a stable processing environment and allows you to link up with your Google account saving time with permissions. Currently, we are supporting the use within SEPAL, but you can run the scripts outside of SEPAL if required, although this will require extra code to account for the various dependencies SEPAL already has built in.
|
|
197
|
-
|
|
198
|
-
1. Login to SEPAL.
|
|
199
|
-
2. Start an instance (see Terminal info) to provide you with free processing power.
|
|
200
|
-
3. If you don’t have SEPAL set up:
|
|
201
|
-
- To create a SEPAL account, please follow the registration steps described [here](https://docs.sepal.io/en/latest/setup/register.html) and then familiarize yourself with the tool by exploring its interface.
|
|
202
|
-
- To create a Google Earth Engine (GEE) account, please follow these steps and don’t forget to initialize the home folder.
|
|
203
|
-
|
|
204
|
-
### Setting Up the Whisp GitHub Repository
|
|
103
|
+
```
|
|
104
|
+
The package relies upon the earth engine api being setup correctly using a registered cloud project
|
|
205
105
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
106
|
+
# Earth Engine project name
|
|
107
|
+
gee_project_name="my-ee-project"
|
|
108
|
+
```
|
|
109
|
+
Where you must replace the GEE project in the
|
|
110
|
+
ee.Initialize(project=gee_project_name)
|
|
209
111
|
|
|
210
|
-
|
|
211
|
-
git clone https://github.com/forestdatapartnership/whisp.git
|
|
212
|
-
```
|
|
112
|
+
Note: this should be a registered cloud project. If unsure of this check pic here: https://developers.google.com/earth-engine/cloud/assets
|
|
213
113
|
|
|
214
|
-
|
|
114
|
+
More info on Whisp can be found in [here](https://openknowledge.fao.org/items/e9284dc7-4b19-4f9c-b3e1-e6c142585865)
|
|
215
115
|
|
|
216
116
|
|
|
217
117
|
## How to add data layers to Whisp
|
|
@@ -219,12 +119,12 @@ SEPAL is closely linked to Google Earth Engine (GEE), a Google-powered Earth-obs
|
|
|
219
119
|
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
|
|
220
120
|
|
|
221
121
|
### Requesting a dataset addition
|
|
222
|
-
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/).
|
|
122
|
+
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.
|
|
223
123
|
|
|
224
124
|
### Adding your own dataset for a bespoke Whisp analysis (using the Python Notebooks)
|
|
225
125
|
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.
|
|
226
126
|
|
|
227
|
-
1) Edit
|
|
127
|
+
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.
|
|
228
128
|
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.
|
|
229
129
|
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.
|
|
230
130
|
|
|
@@ -258,5 +158,33 @@ g. corresponding variable: the name of the function for creating the dataset in
|
|
|
258
158
|
• 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).
|
|
259
159
|
• 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.
|
|
260
160
|
|
|
161
|
+
## Key files
|
|
162
|
+
|
|
163
|
+
# Parameters:
|
|
164
|
+
- `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).
|
|
165
|
+
|
|
166
|
+
### src code
|
|
167
|
+
|
|
168
|
+
Main Whisp analysis functions are found in the following files:
|
|
169
|
+
- `datasets.py` functions for compiling GEE datasets into a single multiband image ready for input into the whisp analysis
|
|
170
|
+
- `stats.py` functions to run Whisp analysis for each GEE dataset, providing results for coverage of each plot as an area in hectares
|
|
171
|
+
-`risk.py` functions for estimating risk of deforestation.
|
|
172
|
+
|
|
261
173
|
## Contributing to the Whisp code base
|
|
262
174
|
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/).
|
|
175
|
+
|
|
176
|
+
Install the package in editable mode with the additional dependencies required for testing and running pre-commit hooks:
|
|
177
|
+
```
|
|
178
|
+
git clone https://github.com/forestdatapartnership/whisp.git
|
|
179
|
+
cd whisp/
|
|
180
|
+
pip install -e .[dev]
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Setup the pre-commit hooks:
|
|
184
|
+
```
|
|
185
|
+
pre-commit install
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
You should be able to run the Pytest suite by simple running the `pytest` command from the repo's root folder.
|
|
189
|
+
|
|
190
|
+
Please read the  for good practice recommendations.
|
|
@@ -4,8 +4,9 @@ build-backend = "poetry.core.masonry.api"
|
|
|
4
4
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
name = "openforis-whisp"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.1.0a0"
|
|
8
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"
|
|
9
10
|
authors = ["Andy Arnell <and.arnell@fao.org>"]
|
|
10
11
|
readme = "README.md"
|
|
11
12
|
license = "MIT"
|
|
@@ -19,6 +20,11 @@ classifiers = [
|
|
|
19
20
|
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
20
21
|
]
|
|
21
22
|
|
|
23
|
+
[tool.poetry.urls]
|
|
24
|
+
"Documentation" = "https://github.com/forestdatapartnership/whisp#readme"
|
|
25
|
+
"Development Branch" = "https://github.com/forestdatapartnership/whisp/tree/package-test-new-structure"
|
|
26
|
+
"Issues" = "https://github.com/forestdatapartnership/whisp/issues"
|
|
27
|
+
|
|
22
28
|
[tool.poetry.dependencies]
|
|
23
29
|
python = ">=3.10"
|
|
24
30
|
earthengine-api = "*"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/parameters/__init__.py
RENAMED
|
File without changes
|
{openforis_whisp-0.0.1 → openforis_whisp-0.1.0a0}/src/openforis_whisp/parameters/config_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|