knitr::opts_chunk$set(echo = TRUE)
To reproduce this analysis, please contact mathis.messager@mail.mcgill.ca to obtain the required raw and pre-processed data, which represent between 60 and 500GB depending on how comprehensive of a re-production is wanted.
This analysis relies as much as possible on good enough practices in scientific computing, which users are encouraged to read.
Structure: the overall project directory is structured with the following sub-directories:
bin/ (compiled code/external packages)
data/ (raw data, not to be altered)
results/ (results of the analysis, mostly reproduceable through code executiong but also includes manually modified results)
src/ (code written for the project)
|---- globalIRmap (source code for analysis in R)
|---- globalIRmap_HydroATLAS_py (source code for formatting of global river network environmental attributes)
|---- globalIRmap_py (source code for formatting of spatial data in Python)
All scripts rely on this structure.
The overall workflow of the project is detailed in the Workflow tab of this website.
The documentation that follows is specifically for the portions of the analysis conducted in Python, which encompass all spatial formatting and analyses.
Prerequisites All GIS analyses in this study require an ESRI ArcGIS license including the Spatial Analyst extension, which itself requires a Windows OS. We used the Python Arcpy module associated with ArcGIS 10.7 in Python 2.7 with 64-bit background processing.
In Git Bash, the following commands illustrate the procedure to make a local copy (i.e. clone) of the Github repository in a newly created directory at C://test_globalIRmap/src :
Mathis@DESKTOP MINGW64 ~ $ cd /c/ Mathis@DESKTOP MINGW64 /c $ mkdir test_globalIRmap Mathis@DESKTOP MINGW64 /c $ mkdir /c/test_globalIRmap/src Mathis@DESKTOP MINGW64 /c $ cd /c/test_globalIRmap/src Mathis@DESKTOP MINGW64 /c/test_globalIRmap/src $ git clone https://github.com/messamat/globalIRmap_py.git Cloning into 'globalIRmap_py'... remote: Enumerating objects: 164, done. remote: Counting objects: 100% (164/164), done. remote: Compressing objects: 100% (108/108), done. Receiving obremote: Total 164 (delta 97), reused 118 (delta 53), pack-reused 0 Receiving objects: 100% (164/164), 116.62 KiB | 1003.00 KiB/s, done. Resolving deltas: 100% (97/97), done.
The documentation that follows is specifically for the portions of the analysis conducted in R, which encompass all statistical analyses and figure-making (aside from maps).
Documentation: this project is organized as an R package, providing documented functions to reproduce and extend the analysis reported in the publication. Note that this package has been written explicitly for this project and may not be suitable for general use. See guidelines below to install the package.
R Workflow: this project is setup with a drake workflow, ensuring reproducibility.
In the drake
philosophy, every action is a function, and every R object is a "target" with dependencies.
Intermediate targets/objects are stored in a .drake
directory.
Dependency management: the R library of this project is managed by renv.
This makes sure that the exact same package versions are used when recreating the project.
When calling renv::restore()
, all required packages will be installed with their specific version.
Please note that this project was built with R version 4.0.3 on a Windows 10 operating system.
The renv packages from this project are not compatible with R versions prior to version 3.6.0.
Syntax: this analysis relies on the data.table syntax, which provides a high-performance version of data.frame. It is concise, faster, and more memory efficient than conventional data.frames and the tidyverse syntax.
Machine learning model development: for random forest model development, this project relies on the mlr3 package and ecosystem (see the mlr3 book for learning its usage), which provides an object-oriented framework for machine learning.
In Git Bash, continuing from the previous example for downloading the Github repository of the Python analysis, the following commands illustrate the procedure to make a local copy of the Github repository in a newly created directory at C://test_globalIRmap/src :
Mathis@DESKTOP MINGW64 /c/test_globalIRmap/src $ git clone https://github.com/messamat/globalIRmap.git Cloning into 'globalIRmap'... remote: Enumerating objects: 116, done. remote: Counting objects: 100% (116/116), done. remote: Compressing objects: 100% (89/89), done. remote: Total 7363 (delta 48), reused 75 (delta 19), pack-reused 7247 Receiving objects: 100% (7363/7363), 1.91 GiB | 3.78 MiB/s, done. Resolving deltas: 100% (925/925), done.
In R Studio for Windows, the following procedure can be used:
The issues tracker is the place to report problems or ask questions
See the repository history for a fine-grained view of progress and changes.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.