Open source tools

open source
osgeo
grass gis
R
qgis
python
Programs like R and GRASS GIS are incredible powerful. But occasionally, you’ll need functionality that is not yet available. Luckily, depending on the kind of functionality, it isn’t terribly difficult to create your own scripts. In the past years I have created a few scripts that, I hope, are useful to others as well.
Author

Paulo van Breugel

Published

May 29, 2023

Introduction

Most of the tools I use are open-source. In part because I believe that the use of open-source software and open data contributes to a more transparent, rapid, and inclusive science, especially in ecology, biogeography, and conservation sciences. But also because open-source tools such as R, GRASS GIS and QGIS are among the best tools available today. And thanks to the extensive documentation and the remarkable support offered by the developer and user communities, it is possible to relatively quickly build simple tools yourself. I have created a few tools in the past few years, which I am glad to share below.

GRASS addons

The GRASS addons I have created or contributed to are listed below. For installation, you should preferably use the extension manager (g.extention or via GUI). If that doesn’t work, see the download link (and see here for installation instructions). For the full list of addons available for GRASS GIS, see here.

Modeling

v.maxent.swd

The v.maxent.swd add-on exports raster values at given point locations as a text file in SWD format for input in Maxent. In addition, the addon can export the environmental raster layers as ascii files. Manual page.

r.maxent.train

With r.maxent.train a Maxent presence-only model can be created using the Maxent software. As input, the addon requires two comma-separated files, one with the species locations and another with background point locations, which can be created using the v.maxent.swd addons. Manual page

r.maxent.predict

The r.maxent.predict addon can be used to apply a previously calculated Maxent model to a new set of environmental raster data. It requires a .lambdas file describing a Maxent model and the name of raster layers for all predictor variables described in the lambdas file. The .lambdas file can be created by the r.maxent.train addon, or by the Maxent software directly. Manual page

A workflow, from data preparation to training a model to model prediction using three GRASS GIS addons.

r.edm.eval

The r.edm.eval addon returns a few evaluation statistics, including the area under the curve (AUC), the maximum true skill statistic (TSS), and the maximum kappa. For all three statistics, the corresponding probability threshold values are also given. Optionally, it draws the receiver operating characteristic (ROC) curve. Manual page

Analysis

r.suitability.regions

The r.suitability.regions add-on can be used for any analysis aimed at the delineation of contiguous regions of high suitability based on a suitability raster layer. It makes the consequences of some basic selection criteria more explicit and helps to visualize the results of specific threshold values for area size and suitability scores. Manual page Tutorial

r.mess

A GRASS GIS addon to compute multivariate environmental similarity surface (MES). This represents how similar a point is to a reference set of points, with respect to a set of predictor variables. Some additional supporting layers are created as well. Manual page

r.meb

Computation of the multivariate environmental bias, which compares the medium environmental conditions in an area (e.g., a country) to those in a subset of that area N (e.g., the protected areas in that country). It thus provides a measure to estimate how well conditions in the subset of an area represent conditions in the whole area, or the other way around, how biased the distribution of the subset is in environmental space. Manual page

r.exdet

Detection and quantification of novel uni- and multi-variate environments following methods developed by Mesgaran et al. (2014). Manual page

r.series.diversity

Computes diversity indices based on two or more input layers representing species (or other categories being used). Indices currently implemented are the Renyi entropy index and a number of specialized cases of the Renyi entropy, viz.the species richness, the Shannon index, the Shannon based effective number of species (ENS), the Simpson index (inverse and Gini variants), and Pielou’s evenness. Manual page

r.niche.similarity

The function computes two metrics to quantify niche similarity or overlap between all pairs of input raster layers: (D) the niche equivalency or similarity for two species following Warren et al. (2009) based on Schoener’s D (Schoener, 1968). Manual page

r.vif

Function to compute the variance inflation factor (VIF) and the square root of the VIF. The variable with the highest VIF will be dropped, and the VIF will be recomputed. This will be repeated until a user-defined VIF threshold value is reached. Manual page

Visualization

r.boxplot

The addon makes it easy to draw a boxplot of raster values or pass a zonal raster layer and get per-class boxplots. Manual

r.series.boxplot

The r.seriesboxplot addon draws boxplots of a series of input raster layers. It can be used to display both temporal patterns and spatial variation. Manual

t.rast.boxplot

Te t.rast.boxplot addon draws boxplots of the raster in a space-time raster data set (strds). The module can be used to display changes over time and how this varies within a area. Manual

v.boxplot

The module offers an easy way to draw a boxplot of the values in a vector map attribute column. There is also the option to group the values of the column according to the categories in a second column (group_by and create one plot with a separate boxplot for each group. Manual

v.scatterplot

With the module, you can plot the values of two columns in the attribute table of an input vector layer as a scatter- or density plot. A linear or polynomial trendline can be added. Likewise, confidence ellipse of the covariance of the two variables can be plotted on top of the scatterplot. Optionally, separate confidence ellipses can be drawn for groups defined in the column groups. Manual

r.out.legend

Create and export an image file with the legend of a raster map. Manual page

Data wrangling

r.random.weight

Generates a raster layer with a weighted random selection of the raster cells (selected cells are assigned a value 1, others a value 0) based on a user-defined weight raster layer. Manual page

r.in.ahn

Addon to download AHN data. The AHN is the Dutch high-resolution DEM data. The r.in.ahn addon uses the WCS protocol to download the data, ensuring that the extent and resolution of the imported data align with those of the original AHN data.’ Manual page

r.recode.attr

Reclass/recode a raster layer based on values in a CSV table. Manual page

v.multi2singlepart

v.multi2singlepart creates a vector layer containing single-part polygon features generated by separating the multipart features of the input vector layer. The attributes of the input layer will be maintained in the output vector layer. Single-part features will not be affected. Manual page

From multipart to singlepart polygons.

v.what.rastlabel

GRASS GIS addon to upload raster values and labels at the positions of vector points to the vector attribute table. Manual page

r.category.trim

Export categories and corresponding colors as a QGIS color file or CSV file. Non-existing categories and their color definitions will be removed. Manual page

R/GRASS scripts

Combining the power of GRASS GIS, which excels in handling and analysis of spatial data, and the vast number of functions for (spatial) data visualization and analysis in R (see R Spatial View) and you have a winner at hand. Below is an example of an R script that garners the strengths of both tools. It uses GRASS GIS in the background for the data crunching and R for the graphical output.

r.eval.strip

R function to create a response plot to evaluate the relationship between environmental variables and the fitted probability of occurrence of individual or ensemble suitability modeling algorithms. on GitHub

Shiny apps & dashboards

Rescale by function

A dashboard that allows you to visualize the effect of different parameter settings of the fuzzify raster functions in QGIS.

Populatiegroei

A app showing how the population numbers change with changing birth, immigration, emigration, and mortality rates.

Central Limit Theorem for Means

Dashboard shows the Central Limit theorem for means.

De wet van de grote nummers

App die de wet van de grote nummers demonstreerd.

Distribution calculator

Calculator to quickly show different statistical distributions.

Correlation simulation

Simple app to visualize correlations between two different variables, based on a user-defined number of observations.

Schijndel Forest Garden dashboard

An example of a dashboard build with R, Rmarkdown, flexdashboard en crosstalk. It shows results of fieldwork carried out by my students in the Schijndel Forest Garden.

Invasive Alien Species bookmarks

A simple dashboard with fact sheets and other relevant information about invasive alien species.

GIS styles

Spatial data layers often come with standard legends / color keys, which provide visualization and even meaning to the data. As a side note, try to avoid the latter! Unfortunately, they are frequently shared in proprietary formats that cannot be used in other programs and are not human-readable. To avoid vendor lock-in and to enable everybody to use it, it is therefore preferable to share color and legend keys in an open format that is also human-readable (i.e., text-based files). See this GitHub page for some examples.

ZIM-wiki export templates

Zim-wiki is a graphical text editor for notes in the form of wiki pages. A great feature of Zim-wiki is that you can easily export the notebook (or part of it) as a website. You can thereby use export templates to determine what the webpages will look like. Below, you can find export templates that you can use for your websites.

Ecodiv-responsive

Template to export your Zim notebook as a responsive/adaptive website that can be viewed in desktop and mobile devices alike. We use this template ourself for the Vegetationmap4africa website and for our tutorials.GitHub page

Ecodiv-mobile

Template to export your Zim notebook as a website with mobile theme. Build with jquerymobile to create a website with a focus on mobile devices, but which will also look good on the desktop. The template offers some pointers to customize the design to fit the user’s need. GitHub page