Skip to main content

This is the Python 'forestatrisk' package

Project description

forestatrisk Python package

Estimating the risk of deforestation in tropical countries

forestatrisk is a Python package for estimating the spatial probability of deforestation in the tropics depending on various spatial environmental variables.

Spatial environmental 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 landscape management (location inside a protected area) for example.


Function .sample() allows the random sampling of observations points considering historical deforestation maps. The sampling is balanced and stratified considering remaining forest and deforested areas after a given period of time. The function also retrieves information from environmental variables for each sampled point. The sampling 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 .model_binomial_iCAR() can be used to fit the deforestation model from the data. A linear Binomial logistic regression model is used to estimate the parameters of the deforestation model. The model includes an intrinsic Conditional Autoregressive (iCAR) process to account for the spatial autocorrelation of the observations (Vieilledent et al. 2014). 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.


Function .predict() allows predicting the deforestation probability on the whole study area using the deforestation model fitted with the .model() function. 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.


We wrote a tutorial using a Jupyter/IPython notebook to show how to use the forestatrisk Python package. We took Madagascar as a case study considering past deforestation on the period 2000-2010, estimating deforestation probability for the year 2010, and projecting the future forest cover in 2050. The notebook is available at the following web adress:


Vieilledent G., C. Merow, J. Guélat, A. M. Latimer, M. Kéry, A. E. Gelfand, A. M. Wilson, F. Mortier and J. A. Silander Jr. 2014. hSDM CRAN release v1.4 for hierarchical Bayesian species distribution models. Zenodo. doi: 10.5281/zenodo.48470


The easiest way to install the forestatrisk Python package is via pip:

~$ sudo pip install --upgrade

but you can also install it executing the file:

~$ git clone
~$ cd forestatrisk
~/forestatrisk$ sudo python install


Map of the probability of deforestation in Madagascar for the year 2010 obtained with forestatrisk. Dark red: high probability of deforestation, Dark green: low probability of deforestation.

Project details

Release history Release notifications

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for forestatrisk, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size forestatrisk-0.1-cp37-cp37m-win_amd64.whl (111.6 kB) File type Wheel Python version cp37 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page