forestatrisk

forestatrisk: a Python package for modelling and forecasting deforestation in the tropics - Published in JOSS (2021)

https://github.com/ghislainv/forestatrisk

Science Score: 95.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 10 DOI reference(s) in README and JOSS metadata
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
    2 of 7 committers (28.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software

Keywords

biodiversity-scenario co2-emissions deforestation deforestation-risk forecasting forest-cover-change ipbes ipcc land-use-change protected-areas python redd roads spatial-analysis spatial-autocorrelation spatial-modelling tropical-forests

Keywords from Contributors

particles

Scientific Fields

Artificial Intelligence and Machine Learning Computer Science - 69% confidence
Economics Social Sciences - 40% confidence
Last synced: 4 months ago · JSON representation

Repository

📦🐍 Python package to model and forecast the risk of deforestation

Basic Info
Statistics
  • Stars: 128
  • Watchers: 6
  • Forks: 29
  • Open Issues: 8
  • Releases: 15
Topics
biodiversity-scenario co2-emissions deforestation deforestation-risk forecasting forest-cover-change ipbes ipcc land-use-change protected-areas python redd roads spatial-analysis spatial-autocorrelation spatial-modelling tropical-forests
Created about 9 years ago · Last pushed 4 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Codemeta

README.rst

..
   # ==============================================================================
   # author          :Ghislain Vieilledent
   # email           :ghislain.vieilledent@cirad.fr
   # web             :https://ecology.ghislainv.fr
   # license         :GPLv3
   # ==============================================================================

.. image:: https://ecology.ghislainv.fr/forestatrisk/_static/logo-far.svg
   :align: right
   :target: https://ecology.ghislainv.fr/forestatrisk
   :alt: Logo forestatrisk
   :width: 140px

``forestatrisk`` Python package
*******************************


|Python version| |PyPI version| |GitHub Actions| |License| |Zenodo| |JOSS|


Overview
========

The ``forestatrisk`` Python package can be used to **model** the
tropical deforestation spatially, **predict** the spatial risk of
deforestation, and **forecast** the future forest cover in the
tropics. It provides functions to estimate the spatial probability of
deforestation as a function of various spatial explanatory variables.

Spatial explanatory variables can be derived from topography
(altitude, slope, and aspect), accessibility (distance to roads,
towns, and forest edge), deforestation history (distance to previous
deforestation), or land conservation status (eg. protected area) for
example.

.. image:: https://ecology.ghislainv.fr/forestatrisk/_static/banner_forestatrisk.png
   :align: center
   :target: https://ecology.ghislainv.fr/forestatrisk
   :alt: banner_forestatrisk

Scientific publication
======================

**Vieilledent G.** 2021. ``forestatrisk``: a Python package for
modelling and forecasting deforestation in the tropics.
*Journal of Open Source Software*. 6(59): 2975.
[doi: `10.21105/joss.02975 `__]. |pdf|
	   
Statement of Need
=================

Spatial modelling of the deforestation allows identifying the main
factors determining the spatial risk of deforestation and quantifying
their relative effects. Forecasting forest cover change is paramount
as it allows anticipating the consequences of deforestation (in terms
of carbon emissions or biodiversity loss) under various technological,
political and socio-economic scenarios, and informs decision makers
accordingly. Because both biodiversity and carbon vary greatly in
space, it is necessary to provide spatial forecasts of forest cover
change to properly quantify biodiversity loss and carbon emissions
associated with future deforestation.

The ``forestatrisk`` Python package can be used to model the tropical
deforestation spatially, predict the spatial risk of deforestation,
and forecast the future forest cover in the tropics. The spatial data
used to model deforestation come from georeferenced raster files,
which can be very large (several gigabytes). The functions available
in the ``forestatrisk`` package process large rasters by blocks of
data, making calculations fast and efficient. This allows
deforestation to be modeled over large geographic areas (e.g. at the
scale of a country) and at high spatial resolution
(eg. ≤ 30 m). The ``forestatrisk`` package offers the possibility
of using logistic regression with auto-correlated spatial random
effects to model the deforestation process. The spatial random effects
make possible to structure the residual spatial variability of the
deforestation process, not explained by the variables of the model and
often very large. In addition to these new features, the
``forestatrisk`` Python package is open source (GPLv3 license),
cross-platform, scriptable (via Python), user-friendly (functions
provided with full documentation and examples), and easily extendable
(with additional statistical models for example). The ``forestatrisk``
Python package has been used to model deforestation and predict future
forest cover by 2100 across the humid tropics
(``__).

Installation
============

You will need several dependencies to run the ``forestatrisk`` Python
package. The best way to install the package is to create a Python
virtual environment, either through ``conda`` (recommended) or ``virtualenv``.

Using ``virtualenv``
++++++++++++++++++++

The easiest way to install the ``forestatrisk`` Python package is via `pip `_ in the *OSGeo4W Shell* for Windows or in a virtual environment for Linux.

For Linux, create and activate a virtual environment before installing ``geefcc`` with ``pip``:

.. code-block:: shell

   cd ~
   # Create a directory for virtual environments
   mkdir venvs
   # Create the virtual environment with venv
   python3 -m venv ~/venvs/venv-geefcc
   # Activate (start) the virtual environment
   source ~/venvs/venv-geefcc/bin/activate

Install Python dependencies and ``forestatrisk`` in the *OSGeo4W Shell* or in the newly created virtual environment:
   
.. code-block:: shell
   
   # Upgrade pip, setuptools, and wheel
   python3 -m pip install --upgrade pip setuptools wheel
   # Install numpy
   python3 -m numpy
   # Install gdal Python bindings (the correct version)
   python3 -m pip install gdal==$(gdal-config --version)
   # Install forestatrisk. This will install all other dependencies
   python3 -m pip install forestatrisk

If you want to install the development version of ``forestatrisk``, replace the last line with:

.. code-block:: shell

   python3 -m pip install https://github.com/ghislainv/forestatrisk/archive/master.zip

To deactivate and delete the virtual environment:

.. code-block:: shell
		
   deactivate
   rm -R ~/venvs/venv-forestatrisk # Just remove the repository

In case of problem while installing GDAL Python bindings, try the following command:

.. code-block:: shell
		
   python3 -m pip install --no-cache-dir --force-reinstall gdal==$(gdal-config --version)


Using ``conda``
+++++++++++++++

You first need to have ``miniconda3`` installed (see `here
`__).

Then, create a conda environment (details `here
`__)
and install the ``forestatrisk`` package with the following commands:

.. code-block:: shell
		
   conda create --name conda-far -c conda-forge python gdal numpy matplotlib pandas patsy pip statsmodels earthengine-api --yes
   conda activate conda-far
   pip install pywdpa scikit-learn # Packages not available with conda
   pip install forestatrisk # For PyPI version
   # pip install https://github.com/ghislainv/forestatrisk/archive/master.zip # For GitHub dev version
   # conda install -c conda-forge python-dotenv --yes  # Additional libraries if needed

To deactivate and delete the conda environment:

.. code-block:: shell
		
   conda deactivate
   conda env remove --name conda-far

Installation testing
++++++++++++++++++++

You can test that the package has been correctly installed using the
command ``forestatrisk`` in a terminal:

.. code-block:: shell

  forestatrisk

This should return a short description of the ``forestatrisk`` package
and the version number:

.. code-block:: shell

  # forestatrisk: modelling and forecasting deforestation in the tropics.
  # https://ecology.ghislainv.fr/forestatrisk/
  # forestatrisk version x.x.

You can also test the package following the `Get
started
`__
tutorial.
   
Main functionalities
====================

Sample
++++++

Function ``.sample()`` sample observations points from a forest cover
change map. The sample is balanced and stratified between deforested
and non-deforested pixels. The function also retrieves information
from explanatory variables for each sampled point. Sampling is done by
block to allow computation on large study areas (e.g. country or
continental scale) with a high spatial resolution (e.g. 30m).

Model
+++++

Function ``.model_binomial_iCAR()`` can be used to fit the
deforestation model. A linear Binomial logistic regression model is
used in this case. The model includes an intrinsic Conditional
Autoregressive (iCAR) process to account for the spatial
autocorrelation of the observations. Parameter inference is done in a
hierarchical Bayesian framework. The function calls a Gibbs sampler
with a Metropolis algorithm written in pure C code to reduce
computation time.

Other models (such as a simple GLM or a Random Forest model) can also
be used.

Predict and project
+++++++++++++++++++

Function ``.predict()`` allows predicting the deforestation
probability on the whole study area using the deforestation model
fitted with ``.model_*()`` functions. The prediction is done by block
to allow the computation on large study areas (e.g. country or
continental scale) with a high spatial resolution (e.g. 30m).

Function ``.deforest()`` predicts the future forest cover map based on a
raster of probability of deforestation (rescaled from 1 to 65535),
which is obtained from function ``.predict()``, and an area (in
hectares) to be deforested.

Validate
++++++++

A set of functions (eg. ``.cross_validation()`` or
``.map_accuracy()``\ ) is also provided to perform model and map
validation.

Contributing
============

The ``forestatrisk`` Python package is Open Source and released under
the `GNU GPL version 3 license
`__. Anybody
who is interested can contribute to the package development following
our `Community guidelines
`__. Every
contributor must agree to follow the project's `Code of conduct
`__.


.. |Python version| image:: https://img.shields.io/pypi/pyversions/forestatrisk?logo=python&logoColor=ffd43b&color=306998
   :target: https://pypi.org/project/forestatrisk
   :alt: Python version

.. |PyPI version| image:: https://img.shields.io/pypi/v/forestatrisk
   :target: https://pypi.org/project/forestatrisk
   :alt: PyPI version

.. |GitHub Actions| image:: https://github.com/ghislainv/forestatrisk/workflows/PyPkg/badge.svg
   :target: https://github.com/ghislainv/forestatrisk/actions
   :alt: GitHub Actions
	 
.. |License| image:: https://img.shields.io/badge/licence-GPLv3-8f10cb.svg
   :target: https://www.gnu.org/licenses/gpl-3.0.html
   :alt: License GPLv3	 

.. |Zenodo| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.996337.svg
   :target: https://doi.org/10.5281/zenodo.996337
   :alt: Zenodo

.. |JOSS| image:: https://joss.theoj.org/papers/10.21105/joss.02975/status.svg
   :target: https://doi.org/10.21105/joss.02975
   :alt: JOSS

.. |pdf| image:: https://ecology.ghislainv.fr/forestatrisk/_static/logo-pdf.png
   :target: https://www.theoj.org/joss-papers/joss.02975/10.21105.joss.02975.pdf
   :alt: pdf

Owner

  • Name: Ghislain Vieilledent
  • Login: ghislainv
  • Kind: user
  • Location: Pacific / Noumea
  • Company: Cirad

Researcher in ecology and applied statistics at Cirad

JOSS Publication

forestatrisk: a Python package for modelling and forecasting deforestation in the tropics
Published
March 02, 2021
Volume 6, Issue 59, Page 2975
Authors
Ghislain Vieilledent ORCID
CIRAD, UMR AMAP, F--34398 Montpellier, France, CIRAD, Forêts et Sociétés, F--34398 Montpellier, France., AMAP, Univ Montpellier, CIRAD, CNRS, INRAE, IRD, Montpellier, France., European Commission, Joint Research Centre (JRC), I--21027 Ispra (VA), Italy.
Editor
Katy Barnhart ORCID
Tags
Python land use change spatial modelling spatial analysis forecasting spatial autocorrelation tropical forests roads protected areas biodiversity scenario ipbes co2 emissions ipcc

CodeMeta (codemeta.json)

{
  "@context": "https://raw.githubusercontent.com/codemeta/codemeta/master/codemeta.jsonld",
  "@type": "Code",
  "author": [
    {
      "@id": "http://orcid.org/0000-0002-1685-4997",
      "@type": "Person",
      "email": "ghislain.vieilledent@cirad.fr",
      "name": "Ghislain Vieilledent",
      "affiliation": "CIRAD, UMR AMAP, F--34398 Montpellier, France"
    }
  ],
  "identifier": "https://doi.org/10.5281/zenodo.996337",
  "codeRepository": "https://github.com/ghislainv/forestatrisk",
  "datePublished": "2020-12-08",
  "dateModified": "2020-12-08",
  "dateCreated": "2020-12-08",
  "description": "ForestAtRisk: A Python package for modelling and forecasting deforestation in the tropics.",
  "keywords": "python, land use change, spatial modelling, spatial analysis, forecasting, spatial autocorrelation, tropical forests, roads, protected areas, biodiversity scenarios, IPBES, CO2 emissions, IPCC, deforestation risk",
  "license": "GPL v3.0",
  "title": "ForestAtRisk",
  "version": "v0.2"
}

GitHub Events

Total
  • Create event: 10
  • Release event: 7
  • Issues event: 2
  • Watch event: 9
  • Delete event: 3
  • Push event: 42
  • Fork event: 2
Last Year
  • Create event: 10
  • Release event: 7
  • Issues event: 2
  • Watch event: 9
  • Delete event: 3
  • Push event: 42
  • Fork event: 2

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 686
  • Total Committers: 7
  • Avg Commits per committer: 98.0
  • Development Distribution Score (DDS): 0.025
Past Year
  • Commits: 109
  • Committers: 2
  • Avg Commits per committer: 54.5
  • Development Distribution Score (DDS): 0.028
Top Committers
Name Email Commits
Ghislain Vieilledent g****t@c****r 669
Pierrick Rambaud p****9@g****m 8
thomasarsouze t****e@z****m 4
Daniel S. Katz d****z@i****g 2
Katy Barnhart k****t@u****v 1
Juan m****r@g****m 1
Ethan White (he/him) e****n@w****g 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 38
  • Total pull requests: 53
  • Average time to close issues: 12 months
  • Average time to close pull requests: 6 days
  • Total issue authors: 9
  • Total pull request authors: 7
  • Average comments per issue: 1.21
  • Average comments per pull request: 0.26
  • Merged pull requests: 51
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: less than a minute
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ghislainv (24)
  • ricardozwarg (4)
  • thomasarsouze (3)
  • molgor (2)
  • 12rambau (2)
  • datamongerbonny (1)
  • felipedantas-pi (1)
  • soumyadiptapete (1)
  • Wescruise (1)
Pull Request Authors
  • ghislainv (42)
  • thomasarsouze (6)
  • 12rambau (3)
  • ethanwhite (2)
  • kbarnhart (1)
  • molgor (1)
  • danielskatz (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 600 last-month
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 35
  • Total maintainers: 1
proxy.golang.org: github.com/ghislainv/forestatrisk
  • Versions: 14
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.7%
Last synced: 4 months ago
pypi.org: forestatrisk

Modelling and forecasting deforestation in the tropics

  • Versions: 21
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 600 Last month
Rankings
Stargazers count: 6.9%
Dependent packages count: 7.3%
Forks count: 7.6%
Downloads: 9.6%
Average: 10.7%
Dependent repos count: 22.1%
Maintainers (1)
Last synced: 4 months ago

Dependencies

.github/workflows/github-pages.yml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/python-package.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
.github/workflows/wheel-pypi.yml actions
  • actions/checkout v3 composite
  • actions/download-artifact v3 composite
  • actions/setup-python v4 composite
  • actions/upload-artifact v3 composite
  • pypa/gh-action-pypi-publish release/v1 composite
.github/workflows/lint.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v5 composite
  • pre-commit/action v3.0.0 composite
requirements.txt pypi
  • earthengine-api *
  • gdal *
  • matplotlib *
  • numpy *
  • pandas *
  • patsy *
  • pywdpa *
  • scikit-learn *
setup.py pypi
  • earthengine-api *
  • gdal *
  • matplotlib *
  • numpy *
  • pandas *
  • patsy *
  • pywdpa *
  • scikit-learn *