Use R to get gbif data into a GRASS database



The Global Biodiversity Information Facility (GBIF) is an international open data infrastructure that allows anyone, anywhere to access data about all types of life on Earth, shared across national boundaries via the Internet. GBIF provides a single point of access through to species records shared freely by hundreds of institutions worldwide. The data accessible through GBIF relate to evidence about more than 1.6 million species, collected over three centuries of natural history exploration and including current observations from citizen scientists, researchers and automated monitoring programs.

There are various ways to import GBIF data, including directly from the website as comma delimited file (csv) and using the addon for GRASS (I’ll post an example using this addon at a later stage). Here, however, I’ll use the rgbif package for R to obtain the data. In the link section some tutorials are listed that illustrate the use of other R packages. Continue reading “Use R to get gbif data into a GRASS database”

VIF stepwise variable selection


In modelling, multicollinearity in the set of predictor variables is a potential problem. One way to detect multicollinearity is the variance inflation factor analysis (VIF). In GRASS GIS, the VIF for a set of variables can be computed using the r.vif addon. This addon furthermore let’s you select a subset of variables using a stepwise variable selection procedure, in which variables are removed till the highest VIF values is less than a user-defined threshold value. In this post I introduce the addon and provide some examples how to use the addon. Continue reading “VIF stepwise variable selection”

Sample raster values at point location in QGIS – yet another way

A while back I wrote how one can sample raster values at point locations in QGIS using the Saga function ‘Add grid values to point’, which is available in the processing toolbox. Recently it was reported here that values uploaded from a floating raster layer are rounded up to an integer. I tried it myself in Saga, and it seems to work fine for me. But if you are running in problems with a function, it is good to remember that in QGIS you have have access to many libraries from multiple software tools. This means there are often more than one way to get things done.

And indeed, the processing toolbox offers another tool to sample raster values at point location; the GRASS GIS v.what.rast.points function. In this post I describe how to use this tool directly in GRASS, but you can use the tool in QGIS as well, as illustrated below. Continue reading “Sample raster values at point location in QGIS – yet another way”

GRASS GIS addon to create smoothed legend image

I just uploaded a small addon for GRASS GIS, r.out.legend, with which you can quickly create a smoothed legend image for floating point raster maps (continuous values as opposed to categories).

You just select the raster layer, the dimensions and resolution required and the name of the output image. Other options are to change the font and font size and the image type (PNG, BMP, PDF and SVG).

Example of an output of the r.out.legend addon

Continue reading “GRASS GIS addon to create smoothed legend image”

Compiling the gdal-grass plugin for GRASS 7

The idea of the GDAL-GRASS plugin is to directly access GRASS raster and vector data from outside. Any GDAL enabled software (QGIS, R, …) can read and write through the plugin from the GRASS database. The different steps are explained on the grass wiki. Mostly as a note to self, I am copying those steps below (for GRASS 7), with some small changes that made this work for me. Continue reading “Compiling the gdal-grass plugin for GRASS 7”

The r.series function applied to a range of values

One of the fundamental functions in GRASS GIS is the r.series function. It makes each output cell value a function of the values assigned to the corresponding cells in the input raster map layers. I use it very often in my analyses, but I only recently ‘discovered’ this option to ignore values outside an user-defined range. Continue reading “The r.series function applied to a range of values”

PyGRASS equivalent of piping results from one function to another

When using GRASS commands on the command line, one very neat little trick is to ‘pipe’ results from one function directly to another. An example I used in an earlier post is:

r.category My_map | r.category My_map rules=-

So, how does that works in python using pygrass?
Continue reading “PyGRASS equivalent of piping results from one function to another”