Skip to content

Commit

Permalink
Deploying to gh-pages from @ f818c87 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ghislainv committed Jun 23, 2024
1 parent 362ff73 commit 1cb9dcb
Show file tree
Hide file tree
Showing 23 changed files with 127 additions and 45 deletions.
Binary file added _images/icon_deforisk_toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/icon_python_console_toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/interface_MTQ-tuto-benchmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/interface_MTQ-tuto-variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed _images/interface_MTQ-tuto.png
Binary file not shown.
Binary file added _images/qgis-benchmark-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _images/qgis-variables-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed _images/qgis-variables.png
Binary file not shown.
55 changes: 51 additions & 4 deletions _sources/get_started.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,30 @@ Get started
Introduction
------------

To test the plugin installation and have a first look at its functionalities, try it on a small area of interest (AOI) such as the `Martinique <https://en.wikipedia.org/wiki/Martinique>`_ island (1128 km\ :sup:`2`\) which as the MTQ iso code. Testing the plugin on a small AOI has the advantage of making computations faster so that you can directly see the outputs, interpret the results, and understand the functioning of the plugin.
.. |ico_py| image:: _static/icon_python_console_toolbar.png
:class: no-scaled-link
.. |ico_deforisk| image:: _static/icon_deforisk_toolbar.png
:class: no-scaled-link

Open QGIS on your computer. To have access to log messages, activate the “Log Messages” panel in QGIS going to ``View > Panel > Log Messages`` in the Menu. When using a plugin, it is also a good habit to open the Python console in QGIS to have access to Python messages returned in the console. To open it, click on the Python icon |ico_py| in the “Plugins Toolbar”. If the toolbar is not visible, activate it going to ``View > Toolbars > Plugins Toolbar`` in the Menu.

Once the plugin has been installed (see `Installation <installation.html>`_ instructions), open the plugin clicking on its icon |ico_deforisk|. You should see the versions of the dependencies installed in your environment written in the Python console. Check that these version numbers correspond to the last version for each dependency. Otherwise upgrade your dependencies.

.. code:: python
osmconvert 0.8.10
osmfilter 1.4.4
geefcc 0.1.3
pywdpa 0.1.6
forestatrisk 1.2
riskmapjnr 1.3
To test the plugin and have a first look at its functionalities, try it on a small area of interest (AOI) such as the `Martinique <https://en.wikipedia.org/wiki/Martinique>`_ island (1128 km\ :sup:`2`\) which has the MTQ iso code. Testing the plugin on a small AOI has the advantage of making computations fast so that you can directly see the outputs, interpret the results, and understand the functioning of the plugin.

Get variables
-------------

.. image:: _static/interface_MTQ-tuto.png
.. image:: _static/interface_MTQ-tuto-variables.png
:alt: MTQ variables

- ``Working directory``: Select your working directory. Here ``/home/<username>/deforisk/MTQ-tuto``, but it could be ``C:\Users\<username>\deforisk\MTQ-tuto`` on Windows for example.
Expand All @@ -39,15 +57,44 @@ Get variables

- ``Projection EPSG code``: EPSG:5490

Click the run button and you should get the following layer on QGIS:
Click the run button. A forest cover change map appears in the list of QGIS layers (see image below and click to enlarge) and a plot of the forest cover change ``fcc123.png`` is created in folder ``outputs/variables``. New folders are created in the working directory among which the ``data_raw`` folder which includes raw data with intermediary files and the ``data`` folder which includes processed data used for models and plots. You can visualize the road network for example adding the ``roads_proj.shp`` vector file, which is located in the ``data_raw`` directory, in QGIS.

.. image:: _static/qgis-variables.png
.. image:: _static/qgis-variables-results.png
:width: 650px
:alt: QGIS variables

Benchmark model
---------------

.. image:: _static/interface_MTQ-tuto-benchmark.png
:alt: MTQ variables

Fit model to data
~~~~~~~~~~~~~~~~~

- ``Deforestation threshold (%)``: 99.5%

- ``Max. distance to forest edge (m)``: 2500

- ``calib. period``: Checked, the model is fitted over the calibration period (t1--t2).

- ``hist. period``: Checked, the model is fitted over the historical period (t1--t3).

Click the ``Run`` button to estimate the deforestation risk with the benchmark model and predict the deforestation risk at t1 using both data on the calibration and historical periods. Maps with classes of deforestation risk are added to the list of QGIS layers (see image below) and new folders with results are created in the ``outputs/rmj_benchmark/`` directory including the ``<period>/defrate_cat_bm_<period>.csv`` tables with deforestation rates for each class of deforestation risk (see details `here <plugin_api.html#defrate-table>`_).

.. image:: _static/qgis-benchmark-results.png
:width: 650px
:alt: QGIS variables

Predict the deforestation risk
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- ``t2 validation``: Checked, computes predictions at t2 for validation (using the benchmark model fitted over the calibration period).

- ``t3 forecast``: Checked, computes predictions at t3 for forecasting (using the benchmark model fitted over the historical period).

Click the ``Run`` button to predict the deforestation risk at t2 and t3 using the benchmark model. Maps with classes of deforestation risk are added to the list of QGIS layers (see image below) and new folders with results are created in the ``outputs/rmj_benchmark/`` directory.

Forestatrisk models
-------------------

Expand Down
16 changes: 8 additions & 8 deletions _sources/installation.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ To be able to use the ``deforisk`` QGIS plugin, you need to activate the develop

- Read the disclaimer for the setting you choose. Click “Yes” to accept the change.

Install Qgis and GDAL on Windows
Install QGIS and GDAL on Windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To install Qgis and GDAL on Windows, use the `OSGeo4W <https://trac.osgeo.org/osgeo4w/>`_ network installer. OSGeo4W is a binary distribution of a broad set of open source geospatial software for Windows environments (Windows 11 down to 7). Select *Express Install* and install both Qgis and GDAL. Several Gb of space will be needed on disk to install these programs. This will also install *OSGeo4W Shell* to execute command lines.
To install QGIS and GDAL on Windows, use the `OSGeo4W <https://trac.osgeo.org/osgeo4w/>`_ network installer. OSGeo4W is a binary distribution of a broad set of open source geospatial software for Windows environments (Windows 11 down to 7). Select *Express Install* and install both QGIS and GDAL. Several Gb of space will be needed on disk to install these programs. This will also install *OSGeo4W Shell* to execute command lines.

Install the ``forestatrisk`` and ``riskmapjnr`` Python packages on Windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -50,10 +50,10 @@ Note: In case of problems, you can check the version of Python used by OSGeo4W u
On Unix-like systems (Linux and macOS)
--------------------------------------

Install Qgis and GDAL on Unix-like systems
Install QGIS and GDAL on Unix-like systems
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Install Qgis and GDAL on your system, for example using ``apt-get`` for Debian/Ubuntu Linux distributions.
Install QGIS and GDAL on your system, for example using ``apt-get`` for Debian/Ubuntu Linux distributions.

.. code:: shell
Expand All @@ -79,7 +79,7 @@ On recent systems, you cannot use pip to install Python packages system-wide. As
python3 -m pip install forestatrisk riskmapjnr gdal==$(gdal-config --version)
deactivate
Then, in the ``startup.py`` `Python file <https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/intro.html#running-python-code-when-qgis-starts>`_, add the following two lines, adapting the path to your specific case (check the Python version). These two lines will be executed when Qgis starts and will add the path to the packages installed in the virtual environment to ``sys.path``.
Then, in the ``startup.py`` `Python file <https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/intro.html#running-python-code-when-qgis-starts>`_, add the following two lines, adapting the path to your specific case (check the Python version). These two lines will be executed when QGIS starts and will add the path to the packages installed in the virtual environment to ``sys.path``.

.. code:: python
Expand Down Expand Up @@ -113,13 +113,13 @@ In the ``deforisk`` plugin, for the ``WDPA access`` argument available in the
:width: 500px
:alt: WDPA access

Installing the ``deforisk`` plugin in Qgis
Installing the ``deforisk`` plugin in QGIS
------------------------------------------

- Download the ``deforisk`` `zip file <https://github.com/ghislainv/deforisk-qgis-plugin/archive/refs/heads/main.zip>`_ from GitHub.

- Open Qgis.
- Open QGIS.

- In Qgis menu bar, go to ``Extensions/Install extensions/Install from ZIP``.
- In QGIS menu bar, go to ``Extensions/Install extensions/Install from ZIP``.

- Select the zip file that has been downloaded.
16 changes: 8 additions & 8 deletions _sources/plugin_api.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This box is for collecting the information needed to download the data and compu

- ``Working directory``: Path to the working directory where all the data and model outputs will be stored.

- ``Area Of Interest``: Country ISO 3166-1 alpha-3 code (e.g. MTQ) or path to GPKG vector file in lat/lon delimiting the area of interest (jurisdiction) and the sub-jurisdictions. The GPKG vector file must include two layers, the first one must be named “aoi” for the jurisdiction and the second one must be named “subj” for subjurisdictions. This GPKG vector file can be manually obtained using Qgis tools and data from the Global Administrative Areas (`GADM <https://gadm.org/download_country.html>`_) website. An example is given in the following article on using `subnational jurisdictions <articles/subnational_jurisd.html>`_.
- ``Area Of Interest``: Country ISO 3166-1 alpha-3 code (e.g. MTQ) or path to GPKG vector file in lat/lon delimiting the area of interest (jurisdiction) and the sub-jurisdictions. The GPKG vector file must include two layers, the first one must be named “aoi” for the jurisdiction and the second one must be named “subj” for subjurisdictions. This GPKG vector file can be manually obtained using QGIS tools and data from the Global Administrative Areas (`GADM <https://gadm.org/download_country.html>`_) website. An example is given in the following article on using `subnational jurisdictions <articles/subnational_jurisd.html>`_.

- ``Years``: Years delimiting the two periods (calibration and validation periods) for forest cover change observations. Three years must be provided. Years can be in the interval 2001--2024 for GFC (GFC does not provide tree cover loss for the year 2000) and 2000--2023 for TMF.

Expand All @@ -45,7 +45,7 @@ This box is for collecting the information needed to download the data and compu

- ``Projection EPSG code``: EPSG code of the coordinate reference system used for projecting maps.

Pushing the ``Run`` button in this box will download the data and compute the variables in the background. When the operation is finished, a forest cover change map appears in the list of Qgis layers and a plot of the forest cover change ``fcc123.png`` is created in folder ``outputs/variables``. New folders are created in the working directory:
Pushing the ``Run`` button in this box will download the data and compute the variables in the background. When the operation is finished, a forest cover change map appears in the list of QGIS layers and a plot of the forest cover change ``fcc123.png`` is created in folder ``outputs/variables``. New folders are created in the working directory:

Six data folders are created:

Expand All @@ -69,7 +69,7 @@ Three other folders are created:

- ``outputs/variables``: Output for variables.

- ``qgis_layer_style``: Layer styles for Qgis.
- ``qgis_layer_style``: Layer styles for QGIS.

Benchmark
---------
Expand Down Expand Up @@ -143,7 +143,7 @@ This step is for predicting the deforestation risk and deriving risk maps using

- ``t3 forecast``: If checked, computes predictions at t3 for forecasting (using the benchmark model fitted over the historical period).

Pushing the ``Run`` button in this box will use the benchmark models for predictions. Note that you cannot make predictions if you have not fitted the models (see previous step). When the operation is finished, rasters representing the classes of deforestation risk appear in the list of Qgis layers. You can navigate the different maps to see how the risk of deforestation is changing in space for the different dates. For example, you can have a look at the effect of the distance to forest edge.
Pushing the ``Run`` button in this box will use the benchmark models for predictions. Note that you cannot make predictions if you have not fitted the models (see previous step). When the operation is finished, rasters representing the classes of deforestation risk appear in the list of QGIS layers. You can navigate the different maps to see how the risk of deforestation is changing in space for the different dates. For example, you can have a look at the effect of the distance to forest edge.

The following folders are created: ``outputs/rmj_benchmark/validation`` and ``outputs/rmj_benchmark/forecast``.The following files are added to these folders:

Expand Down Expand Up @@ -175,7 +175,7 @@ This box is for collecting the information needed to sample the deforestation ob

- ``hist. period``: If checked, the observations are sampled for the historical period (t1--t3).

Pushing the ``Run`` button in this box will sample the observations. Note that you cannot sample the observations before downloading and computing the variables (see previous step). When the operation is finished, the sampled observations appear in the list of Qgis layers. You can navigate the map to confirm that about half the observations have been sampled in the deforested area and half in the non-deforested area.
Pushing the ``Run`` button in this box will sample the observations. Note that you cannot sample the observations before downloading and computing the variables (see previous step). When the operation is finished, the sampled observations appear in the list of QGIS layers. You can navigate the map to confirm that about half the observations have been sampled in the deforested area and half in the non-deforested area.

The folder ``outputs/far_models`` is created with ``calibration`` and ``historical`` subfolders if ``calib. period`` and ``hist. period`` have been checked respectively. Files ``sample.txt``, ``sample_size.csv``, ``csize_icar.txt``, and ``correlation.pdf`` are added to the output folders for each period.

Expand Down Expand Up @@ -235,7 +235,7 @@ This step is for predicting the deforestation risk and deriving risk maps using

- ``t3 forecast``: If checked, computes predictions at t3 for forecasting (using models fitted over the historical period).

Pushing the ``Run`` button in this box will use the statistical models for predictions. Note that you cannot make predictions if you have not fitted the models (see previous step). When the operation is finished, rasters representing the classes of deforestation risk appear in the list of Qgis layers. You can navigate the different maps to see how the risk of deforestation is changing in space for the different dates. For example, you can have a look at the effect of the distance to forest edge, of the distance to roads, or of protected areas.
Pushing the ``Run`` button in this box will use the statistical models for predictions. Note that you cannot make predictions if you have not fitted the models (see previous step). When the operation is finished, rasters representing the classes of deforestation risk appear in the list of QGIS layers. You can navigate the different maps to see how the risk of deforestation is changing in space for the different dates. For example, you can have a look at the effect of the distance to forest edge, of the distance to roads, or of protected areas.

The following folders are created for each period: ``outputs/far_models/<period>``. The following files are created for each model, date or period:

Expand Down Expand Up @@ -290,15 +290,15 @@ This step is for predicting the deforestation risk and deriving risk maps using

- ``t3 forecast``: If checked, computes predictions at t3 for forecasting (using models fitted over the historical period).

Pushing the ``Run`` button in this box will use the moving window models for predictions. Note that you cannot make predictions if you have not fitted the models (see previous step). When the operation is finished, rasters representing the classes of deforestation risk appear in the list of Qgis layers. You can navigate the different maps to see how the risk of deforestation is changing in space for the different dates.
Pushing the ``Run`` button in this box will use the moving window models for predictions. Note that you cannot make predictions if you have not fitted the models (see previous step). When the operation is finished, rasters representing the classes of deforestation risk appear in the list of QGIS layers. You can navigate the different maps to see how the risk of deforestation is changing in space for the different dates.

The following folders are created for each period: ``outputs/rmj_benchmark/<period>``. The following files are created for each window size, date or period:

- ``prob_mw_<window_size>_<date>.tif``: Raster with classes of deforestation risk going from 1 (null deforestation risk beyond the distance threshold) to 65535 (highest deforestation risk).

- ``prob_mw_<window_size>_<date>.png``: Plot of the deforestation risk map.

- ``defrate_cat_mw_<window_size>_<period>.csv``: Table with deforestation rates on the period for each class of deforestation risk. See details `above <plugin_api.html#defrate-table>`_ with one exception for moving window models: column ``rate_mod`` is computed as :math:`\theta_{m,1} = 0` and :math:`\theta_{m,i} = ((i - 2) \times 999999 / 65533 + 1) \times 1e^{-6}` for :math:`i \geq 2`. This formula leads to an almost null (:math:`1e^{-6}`) deforestation probability when :math:`i=2` and to a deforestation probability of 1 when :math:`i=65535`.
- ``defrate_cat_mw_<window_size>_<period>.csv``: Table with deforestation rates on the period for each class of deforestation risk. See details `above <plugin_api.html#defrate-table>`_ with one exception for moving window models: column ``rate_mod`` is computed as :math:`\theta_{m,1} = 0` and :math:`\theta_{m,i} = ((i - 2) \times 999999 / 65533 + 1) \times 1e^{-6}` for :math:`i > 1`. This formula leads to an almost null (:math:`1e^{-6}`) deforestation probability when :math:`i=2` and to a deforestation probability of 1 when :math:`i=65535`.

Validation
----------
Expand Down
Binary file added _static/icon_deforisk_toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/icon_python_console_toolbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/interface_MTQ-tuto-benchmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/interface_MTQ-tuto-variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed _static/interface_MTQ-tuto.png
Binary file not shown.
Binary file added _static/qgis-benchmark-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/qgis-variables-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed _static/qgis-variables.png
Binary file not shown.
Loading

0 comments on commit 1cb9dcb

Please sign in to comment.