Modelling and forecasting deforestation in the tropics
Project description
forestatrisk Python package
Overview
The forestatrisk Python package can be used to model and forecast deforestation 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.
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 virtualenv or conda.
Using virtualenv
You first need to have the virtualenv package installed (see here).
Then, create a virtual environment and install the forestatrisk package with the following commands:
cd ~
mkdir venvs # Directory for virtual environments
cd venvs
virtualenv --python=/usr/bin/python3 venv-far
source ~/venvs/venv-far/bin/activate
# Install numpy first
pip install numpy
# Install gdal (the correct version)
pip install --global-option=build_ext --global-option="-I/usr/include/gdal" gdal==$(gdal-config --version)
# pip install forestatrisk # For PyPI version, this will install all other dependencies
pip install https://github.com/ghislainv/forestatrisk/archive/master.zip # For GitHub dev version
pip install statsmodels # Optional additional packages
To deactivate and delete the virtual environment:
deactivate
rm -R ~/venvs/venv-far # Just remove the repository
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:
conda create --name conda-far python gdal numpy matplotlib pandas patsy pip statsmodels --yes
conda activate conda-far
conda install -c conda-forge earthengine-api --yes
pip install pywdpa sklearn # 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 rclone --yes # Potentially interesting libraries
To deactivate and delete the conda environment:
conda deactivate
conda env remove --name conda-far
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for forestatrisk-0.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbb3becf08fc439d720967e5ae22ae5d96634f843e680c7e5d5a5442067b31c4 |
|
MD5 | 2fd3832bc3641cf2765a06f3078033c8 |
|
BLAKE2b-256 | 40631153019e8e02e7b65c1b3daa6642382bccfecefa717737fa3e380898d555 |
Hashes for forestatrisk-0.2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfb3e85ec5fccb7554fe9281d44abbc24ce3b1c9f1423be54dac7424b916125a |
|
MD5 | b99641c3f5b808e39586d4e33f9010c0 |
|
BLAKE2b-256 | fda156fe98b2914a3b7c7859a949f32fc4bce47d09f0228013f02bb9ca59917f |
Hashes for forestatrisk-0.2-cp39-cp39-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a84a2810889c4ec9fbb997a920eb0d7f31022fbba3528e88a67fc5bcba2a951 |
|
MD5 | aa820dd2978722b256a2c23023f0d504 |
|
BLAKE2b-256 | 81446607bc9af6ba7c1797f565fd06047c49041c74ba2a303283acdf5b91e2c6 |
Hashes for forestatrisk-0.2-cp39-cp39-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a4f5e6a59810697ec29206409ded6cf9fe3beea582be9c0bcc95d1e3bb89e6d |
|
MD5 | 5cb42940bf7a233d915196ccd9f0e55e |
|
BLAKE2b-256 | 990f486ed8fb25dccf18c9d0ed80fe816a707437007ffb40abc23668f6cf3e0b |
Hashes for forestatrisk-0.2-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b281f7a80d294bef5ed1bb154b3187a76e3a3c2a22273581ad869f828dc8b35d |
|
MD5 | ddcadccd15cdd74b6c50e2dabeaabe36 |
|
BLAKE2b-256 | 1c39edae96f009bc582e45d1b825e8b263d029b6b20d4203db59d62ee6f190c6 |
Hashes for forestatrisk-0.2-cp39-cp39-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21e23dc3cce0b3672b242dab82c03bafdaee7d5b34fedffb2b8e28689a46388c |
|
MD5 | c04194db8e3b84ffdea2e1d60385cb21 |
|
BLAKE2b-256 | a2d18763febb43d18a3f95df8e0e5b2e592c63bcfe31a7a306f6265f3bd305cf |
Hashes for forestatrisk-0.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 526e5e0cd8cc3205fc2bcae297b111662970dce1a0682ab9b4aa5aee0113db2e |
|
MD5 | d8639b01a13731eeb8cbf3497acd7ff0 |
|
BLAKE2b-256 | cfb3780b2066f92deeec6c6345edd080c0a68cae3622f97c20495aaa3ee0753e |
Hashes for forestatrisk-0.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 873b7c2af48d854ccb59fb562eb7b3c8d28f6887d1a3c92faed5db0b70eac238 |
|
MD5 | c18812ffe00728584c0ffc914a387744 |
|
BLAKE2b-256 | 141570711064f25ed925774dd42df2fa3638e32227ac68c99510fe34c191b648 |
Hashes for forestatrisk-0.2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e541db568897c30455f950a127991e851097a084183fbf6ca54f9b8642ea3844 |
|
MD5 | 78f06764bfe36b6ee21b82934a6595e4 |
|
BLAKE2b-256 | 27705554cdf9531707b65c24caaccf91c5b5f5a717a5d15ed64ac241a7215b0d |
Hashes for forestatrisk-0.2-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cec00d2a989c7827cfc41c6cb184c519745a54317dd24bcf5c1ad25e38a657ae |
|
MD5 | e38050b9107828f7d7f26d76c71f5d89 |
|
BLAKE2b-256 | 14407bddd0f3bad824d0249ded8de559ba51ede3e8439278e6ee35aab8758d6a |
Hashes for forestatrisk-0.2-cp38-cp38-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e6ca48d41f6d5368554107bdfcc76178b19addc832edc303761fb7c589b0b6b |
|
MD5 | 7012a141392063d2a4717ffbfda710ce |
|
BLAKE2b-256 | 8ab06f8a5e56f3d12abca6c945c3dac51cab4e4ead16b4ecad36c88ecb93ae4a |
Hashes for forestatrisk-0.2-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17a90acfa8ed8f51a5ca6d392a25d07d5afdbac88af85282e85b60fdbb804e76 |
|
MD5 | f02e078464e4a1771d14fcf271da33a4 |
|
BLAKE2b-256 | a8aea4a67f4995e38207aacf3a66891242008f94dcfbaa617aef7772a5f4b55d |
Hashes for forestatrisk-0.2-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2f84809f8823a424d85de54707b0fc40ff22ec39d4081f02163ca64a1f35361 |
|
MD5 | 31e19e4973337d81cd16b3dfa8e9989c |
|
BLAKE2b-256 | 5bd14a6e9e27d526df4e4c2022d28f215b2c1ef28d93701d01fba58d59745e3d |
Hashes for forestatrisk-0.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f1b8dbb15dcdb1fe8cf616b9010a771001787ea3a8aa6c055a50d9634cb5db7 |
|
MD5 | 71efda3ffd18e3fef5fa0d1530daff0b |
|
BLAKE2b-256 | 0ae97f909b54b66fb2d9bf58edcde441f46333b10ccbd3bfb1626cab35889240 |
Hashes for forestatrisk-0.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c4d079122c5336291d6f7bc3368c7b6f2cd26a10fe45a7f8f98dc3080b617fd |
|
MD5 | 5ef7eec2b917ca85be4e026c2d5814c8 |
|
BLAKE2b-256 | 6754bd51493f6ed2e5297187e1703a7d8671300bf03017ba6b121d5ccaf01df9 |
Hashes for forestatrisk-0.2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b65e1ba9104d52016c6a6980976d60de73ad56a212111ca6eb5755e5c1641cd8 |
|
MD5 | 9378a85092a29290fb2e0c2083d390ed |
|
BLAKE2b-256 | 9a4dda5bde4919b172646946c397061b761cf97d9843b0da8b7e54d6b0e6c451 |
Hashes for forestatrisk-0.2-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fe42c0cbb7e6e44243f4baa3438309b1d2eedd79d6ccc1e929f9bf95c8b4b30 |
|
MD5 | 5e0657b1ccb76324c0a91006e365dac4 |
|
BLAKE2b-256 | e31ab1b19b0d32b1fb4401ddcf32ea89f6fdbebf65675ad2d585dcb89bb102cc |
Hashes for forestatrisk-0.2-cp37-cp37m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae8dbff6f8b5e120eb3f41cc1cca4c2307a7bb097e39722793442b4d798f9704 |
|
MD5 | 3d082194247c69c188f3e6065365a4f3 |
|
BLAKE2b-256 | 55bb1300ac407a19a52d23fc71a3ea5d3e72d9bc9fcab7861d736709d794c342 |
Hashes for forestatrisk-0.2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 780461f19c05c6bb207a94bd67b353de39acc10f9583ea5832c54ca40f0bce9f |
|
MD5 | 44f64d4b05e13b638a3427e280b81312 |
|
BLAKE2b-256 | 7676b49303b0c7653830683742657a9cc2aebbc5123fabd8f7e76ada7dad5bfb |
Hashes for forestatrisk-0.2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bacecf86d6b10a4c56f408c25f591500082c58baa1a644ea2466f3f922e5df4 |
|
MD5 | 24ae06e865461c618c7165774b7c2a88 |
|
BLAKE2b-256 | d1e5db55bd8f6b145a19b96b4b2c06042895bad6c266e0dff3a04e710b7293c2 |
Hashes for forestatrisk-0.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a8a3abf70562768caaa4200965a6b54d663cbdb2d0522ea304e5fa27539cce9 |
|
MD5 | f53ff9165f87b1690fb7cad54f3ead58 |
|
BLAKE2b-256 | 187ce18abb1b050715ffca1b1cb0ef456449dfd73c500d4f79062a42851a8718 |
Hashes for forestatrisk-0.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 711680ff61fd1aac460b6cce87312c18af300184ba9223a3a08cedf0999ff16b |
|
MD5 | 857d21f094966dd3fe5e63f15a1727fe |
|
BLAKE2b-256 | 19045e540f6e0277abd898fbad473f39014d6144a4e2cb59e45bf323b5a4c386 |
Hashes for forestatrisk-0.2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d2cacd1964b054d26ba800d933ce25feffb8472f20d610372d806a31846d4ba |
|
MD5 | 1730ff236f53466a84dec453a3128f08 |
|
BLAKE2b-256 | 633f418e8b2c6a89e4f30f4b18ea6477e1c44dda44ece223cfe33de5e42738c9 |
Hashes for forestatrisk-0.2-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ed4bc556550e59d09f3cc5f008c5b487e54e13a126ac0c0cbf9e29703a08a8a |
|
MD5 | 8bf468f4989d3821c1f35b882b781f14 |
|
BLAKE2b-256 | 1c6025da811ee42a54443f1a3f0c70e27e4101cbd0ea40e5e039b4742925e7b8 |
Hashes for forestatrisk-0.2-cp36-cp36m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ada4af4becdaec9a92028cf9cf41eb83fa338fb01b14c90e618edc7691a556a |
|
MD5 | 32465798dfb7b5f12415cbf74c0d2fbf |
|
BLAKE2b-256 | 59a00d5ca7ec865f412aad94ff331484666ac32cdbddde31ecf9906066526eb3 |
Hashes for forestatrisk-0.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed3cb800561267c3c8d8965a26bc172e66e303ce5d7d2f01fc86e55986a04974 |
|
MD5 | 786d4f0d1a4b6fe4849b692d757db479 |
|
BLAKE2b-256 | d5a3749742b0242fb61373503e907c857c7dba587ba448f49317e315709a424e |
Hashes for forestatrisk-0.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74bd3d3af073bf1c8794a51bbf976f3e2c26aaaee699dcdef667b0f918823430 |
|
MD5 | ac67a1e885b7c253c375394de194a46a |
|
BLAKE2b-256 | f63c5a92a95e6dab2ec42743e670fce5be32dcddf1b0d66ed4f8b229a96bb234 |
Hashes for forestatrisk-0.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcf466b91553c934cb2976136486e57b23ef7e68f4e7c9eb72adcfd956388065 |
|
MD5 | 7c867ed16c6587d537320474a3491bb1 |
|
BLAKE2b-256 | 7a8c44bcb19eeffee11ede6ffed5a4ebf5a268961cf9219f52e1e68a53e82c54 |
Hashes for forestatrisk-0.2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec8daf85fa981e64d38bad12dad25a77df08eee0b0b8a874330f66eebe887723 |
|
MD5 | 4fb892fdb13e6fa0dde6c841a1c27fc4 |
|
BLAKE2b-256 | f86339a7c6d98eb0c19a5ede26d7be1d925abcf0fe126eb47910a62bba718c00 |
Hashes for forestatrisk-0.2-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d81cb095e6773877911c9399035ef91d458b17b4f2ad704501d73d860bca245c |
|
MD5 | 37dc3e56e509a89cf04eebcc17fc20c7 |
|
BLAKE2b-256 | eefe47cb609683045fcdeafc3d6e59915e4d9def867a05a843c3d33a104974ba |
Hashes for forestatrisk-0.2-cp35-cp35m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 753afd7f278cc73b765e8837a424c73f37da3592cdabda47000265d75af3e3bd |
|
MD5 | 55d3198d54ff240d131316c6667d212f |
|
BLAKE2b-256 | 3ac03b9d2971c5c9c4c6a4ac3cbade47afee56aae29642916c860bef10e3732b |
Hashes for forestatrisk-0.2-cp35-cp35m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b0367c8f76d83247bce5a17e535f749b6a60c18064229c2e08ded52d1e5d826 |
|
MD5 | 923bdadbf2b68800ed5df55ed92dc025 |
|
BLAKE2b-256 | 269130620a25fe6e459f41738d68da3570638438375625de9d2c7625c7210d95 |
Hashes for forestatrisk-0.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85d0d4e0ed747d8d0f46f50a0f2b11d6836f43648488c28a418a97320992c490 |
|
MD5 | 74b540ad0977a9fcb05b7f3f4702e970 |
|
BLAKE2b-256 | c45d20aa79193e6783d812ae96b2b6dcfa84f0ef8f15fde465f3a2884ca3a5e5 |
Hashes for forestatrisk-0.2-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07d5fccb672eb3f75669122dc0c5768f091ed34cdafacbbefe2ba227180e75fe |
|
MD5 | f4430b1c93503897892dc508004600b0 |
|
BLAKE2b-256 | 88fb912a96583a17c10d8a4a8ad54c2cea541de5f67032a2e7cefc0f765fdd39 |
Hashes for forestatrisk-0.2-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bff74e07071a1b9b0adb5d5b59d4932c253bb19bf67d73106baf637feabd998c |
|
MD5 | 1a9100bc7b0773373bdd15e81ce98e13 |
|
BLAKE2b-256 | 03e3d36dcde19de16574fcd26e42f9c7b010e0b206279def2fdfcd076e143745 |
Hashes for forestatrisk-0.2-cp27-cp27mu-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 717c486b0f0fc1f773a0ec715c1500a3ed057a69f2c72d87bcc83c4bab17e961 |
|
MD5 | 947bc7cc6c9b78e422192b45ff0876ed |
|
BLAKE2b-256 | 7a72de237a5ea1141c14515a2a545bbaa5f4516fef4610e866fbe36edf13b400 |
Hashes for forestatrisk-0.2-cp27-cp27mu-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6742bb4d0febebdc957eeb578471f0e97dcb23cff8bdbc962eeb50e546716f4f |
|
MD5 | 67ca4944b6a721ca14ff7f6a30d2ae49 |
|
BLAKE2b-256 | a811048b301902940b6a9fb7460bd772066494e078679bb7b9520438741ceb4e |
Hashes for forestatrisk-0.2-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a1c610d06ab51fad488891d0275aaf6b9e272b8e5f4fefea706118dadeac14e |
|
MD5 | efe13f3798561027365f5f0929b1b23b |
|
BLAKE2b-256 | af7d56e052eb438a138b7a8c26a587fa582c82e744d2327b7623f0e5ed1bb11f |
Hashes for forestatrisk-0.2-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14ce63817ab9d84b932500cbfbbecc13fb705c7593f84929ccfae17a9b67b957 |
|
MD5 | 8f40074e858d986e123989a9e43857e6 |
|
BLAKE2b-256 | 19c627e0beb2be72dad555e462a7bc9a11e4b1ca026b36241df168dfb08f8327 |
Hashes for forestatrisk-0.2-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e20e9bceb96e883671006d2cc05b1af0434c10e68be81b21c8ffcaae32d8bbf7 |
|
MD5 | d0b49f5a51a05c413b6a91b1964805ff |
|
BLAKE2b-256 | 54545746aa1aaf4775e6a1cd4c4c7be234825f4b8ec646d674479d477c40b662 |
Hashes for forestatrisk-0.2-cp27-cp27m-manylinux2010_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe325dffd94e73abeb906aedf04d5104194ee700d77e518d7d33bbf469615fcf |
|
MD5 | 8634bdd72369ac1e91980ef2ab1d3242 |
|
BLAKE2b-256 | 90c71b2d9ff336d8c6513df316ffede154f91c8eed7129213c9fe822f1adec3e |
Hashes for forestatrisk-0.2-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cea0887bc6f4dcc9cbda7e2c0ab8809089a7e32106739af61696b06abce67869 |
|
MD5 | 8310ef892b7d484247c4381719669199 |
|
BLAKE2b-256 | 585ef4900c3372e2ae208e03b57b0be9e9965e1e240f99c006bfde7b1b609a53 |
Hashes for forestatrisk-0.2-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 943febd6344d7080d487a8e421c5a7a1a11040175568619d5cb10c47668dc46b |
|
MD5 | 473033d007b783bd38efc4c95f413d80 |
|
BLAKE2b-256 | 188b08e36cd259ae0c663290c54a4325cff5c3ed2698de9ead56cd2d8109b5ce |
Hashes for forestatrisk-0.2-cp27-cp27m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2c0081bd4acb0d9ef70880ecc5a9c3c8b677b67566fbb97bd6a02da06a0e08f |
|
MD5 | fc60ef0aa92a271f9354165b1f0ad68f |
|
BLAKE2b-256 | fe7adf20713b2454b67c508971a592976b86451cce6eb7060361b8fff22fd29f |