Package: riskmapjnr
riskmapjnrPython packageOverviewTheriskmapjnrPython package can be used to obtainmaps of the
spatial risk of deforestation and forest degradationfollowing the
methodology developed in the context of the Jurisdictional and Nested
REDD+ (JNR) and using only a forest cover change map as input.Statement of NeedTheVCS(Verified Carbon Standard) program allows certified
projects to turn their greenhouse gas (GHG) emission reductions and
removals into tradable carbon credits. Since its launch in 2006, the
VCS program has grown into the world’s largest voluntary GHG program.In the forest sector, programs to mitigate GHG emissions across entire
national or subnational jurisdictions (calledREDD+programs,
i.e. programs aiming at Reducing Emissions from Deforestation and
Forest Degradation) can be accounted for and credited using a
jurisdictional-scale framework, the Jurisdictional and Nested REDD+
(JNR) framework. JNR integrates government-led and project-level
REDD+ activities and establishes a clear pathway for subnational- and
project-level activities to be incorporated within broader REDD+
programs. The JNR framework ensures all projects and other reducing
emissions from deforestation and degradation activities in a given
jurisdiction are developed using consistent baselines and crediting
approaches. They mitigate the risk of “leakage”, i.e. the displacement
of emission-causing activities to areas outside the project boundary,
by monitoring emissions across an entire jurisdictional area.TheJNR Risk Mapping Toolis a “benchmark” methodology that
provides a standardized approach for developing deforestation and
forest degradation risk maps for users of theJNR Allocation Toolin the context of Jurisdictional and Nested REDD+ (JNR)
requirements. The methodology allows deriving a map of the
deforestation (or degradation) risk based on a minimal spatial
information provided by the past deforestation (or degradation) map at
the jurisdictional scale.TheJNR Risk Mapping Toolallows the creation of categorical and
spatially static maps whose categories represent different levels of
risk of deforestation or forest degradation in the validity period of
the Forest Reference Emissions Level (FREL) and throughout the
jurisdictional geographical boundaries. In theJNR Allocation Tool,
the level of risk determines how the jurisdictional FREL is spatially
distributed to nested lower-level jurisdictional programs and
projects.While theJNR Risk Mapping Toolmethodology favors simplicity,
obtaining the risk map is not straightforward. The approach requires
several geoprocessing steps on raster data that can be large,
i.e. covering large spatial extent (eg. national scale) at high
spatial resolution (eg. 30 m). TheriskmapjnrPython package
includes functions to perform these geoprocessing steps and derive a
risk map on any jurisdiction and at any spatial resolution following
theJNR Risk Mapping Toolmethodology.InstallationYou will need several dependencies to run theriskmapjnrPython
package. The best way to install the package is to create a Python
virtual environment, either throughconda(recommended) orvirtualenv.Usingconda(recommended)You first need to haveminiconda3installed (seehere).Then, create a conda environment (detailshere)
and install theriskmapjnrpackage with the following commands:condacreate--nameconda-rmj-cconda-forgepython=3gdalnumpymatplotlibpandaspipscipy--yescondaactivateconda-rmjpipinstallriskmapjnr# For PyPI version
# pip install https://github.com/ghislainv/riskmapjnr/archive/master.zip # For GitHub dev version
# conda install -c conda-forge sphinx flake8 jedi jupyter geopandas descartes folium --yes  # Optional additional packagesTo deactivate and delete the conda environment:condadeactivatecondaenvremove--nameconda-rmjUsingvirtualenvYou first need to have thevirtualenvpackage installed (seehere).Then, create a virtual environment and install theriskmapjnrpackage with the following commands:cd~mkdirvenvs# Directory for virtual environmentscdvenvsvirtualenv--python=/usr/bin/python3venv-rmjsource~/venvs/venv-rmj/bin/activate# Install numpy firstpipinstallnumpy# Install gdal (the correct version)pipinstall--global-option=build_ext--global-option="-I/usr/include/gdal"gdal==$(gdal-config--version)pipinstallriskmapjnr# For PyPI version, this will install all other dependencies
# pip install https://github.com/ghislainv/riskmapjnr/archive/master.zip # For GitHub dev version
# pip install sphinx flake8 jedi jupyter geopandas descartes folium # Optional additional packagesTo deactivate and delete the virtual environment:deactivaterm-R~/venvs/venv-rmj# Just remove the repositoryInstallation testingYou can test that the package has been correctly installed using the
commandriskmapjnrin a terminal:riskmapjnrThis should return a short description of theriskmapjnrpackage
and the version number:# riskmapjnr: Map of deforestation risk following JNR methodology.
# https://ecology.ghislainv.fr/riskmapjnr/
# riskmapjnr version x.x.You can also test the package executing the commands in theGet
startedtutorial.Main functionalitiesTheriskmapjnrpackage includes functions to:Estimate the distance to forest edge beyond which the deforestation
risk is negligible:dist_edge_threshold().Compute local deforestation rates using a moving window whose size
can vary:local_defor_rate().Transform local deforestation rates into categories of
deforestation risks using several slicing algorithms:set_defor_cat_zero()anddefor_cat()Validate maps of deforestation risk and select the map with the
higher accuracy:defrate_per_cat()andvalidation().Theriskmapjnrpackage uses several known Python scientific
packages such asNumPy,SciPy, andPandasfor fast matrix
and vector operations andgdalfor processing georeferenced raster
data. Raster data are divided into blocks of data for in-memory
processing. Such an approach allow processing large raster files with
large geographical extents (e.g. country scale) and high spatial
resolutions (eg. 30 m).ContributingTheriskmapjnrPython package is Open Source and released under
theGNU GPL version 3 license. Anybody
who is interested can contribute to the package development following
ourCommunity guidelines. Every
contributor must agree to follow the project’sCode of conduct.