Just to quickly share this great new website where you can search the documentation of all R packages and functions available on CRAN (6688 R packages and 136342 R functions at the moment of writing!). It offers instant or advanced search options in an easy interface, and there is even a package that allows you to use the search functionality from within R. Check it out on http://www.rdocumentation.org/.
A common objective of correlative species distribution model is to be able to project the potential distribution of the target species into a new environmental space. This can be a new geographic space (e.g., invasive species) or projected future conditions.
One should be very careful in interpreting results if extrapolating to areas with conditions that fall outside the range of reference environmental variation. There are several methods to visualize this uncertainty. On this blog I have for example mentioned the multi-environmental similarity tool in Maxent (also implemented in R in amongst others the dismo package and as an addon for GRASS GIS), which allows you to create maps that provides the similarity of each point to a set of reference points (Elith et al. 2010) and thus provide a quick overview of areas with ‘novel’ conditions.
A disadvantage of this and other methods is that they only consider the ranges of the individual predictors, and ignore the correlation structure of the covariates used to build the model. In reality, it is not unlikely that at a given locations values of each univariate factor fall within the original range of values, but the combination of environmental conditions is new. Continue reading
In R you can use system calls or the spgrass6 package to run GRASS GIS functions. To do this, you need to run R from within GRASS GIS. This is as simple as starting GRASS GIS and subsequently starting R from the command line. See the GRASS-wiki for a more detailed background.
The issue at hand
One of the user-cases is when you want to (1) run a GRASS function on e.g., a raster layer and (2) capture the console output in a R data frame. For example, you can run the following in R:
MyVariables <- execGRASS("r.stats", flags="c", input="MyMap", separator=",", intern=TRUE)
However, the output is not in a very convenient format. Continue reading
The Multivariate Environmental Similarity Surfaces (MESS) is an index that represents how similar a point in space is to a reference set of points, with respect to a set of predictor variables (Elith et al 2010). The function was first implemented as part of the Maxent software package, and is also available in the dismo package for R (see also here and here).
The latter works well on small and medium sized data sets. However, they take a long time to run on larger data sets, e.g., when working with 1km² raster grids covering eastern Africa. I therefore wrote a small R script to compute MESS in GRASS GIS. Continue reading
Linking GRASS GIS and R will give you a very powerful set of geo-spatial analytical tools. The spgrass6 offers a very convenient interface between GRASS GIS and R. You can read more about this package in Bivand, R. 2007. Using the R-GRASS interface. OSGeo Journal 1, 36-38.
Read the whole vector layer
It allows you amongst others to easily import vector data layers from GRASS GIS into R using the function
readVECT6(). This will import the whole vector layer. But what if you you only need to import the attribute table? Importing the whole vector layer would give unnecessarily overhead and would take (much) longer to import. Continue reading
Jean-Pierre Rossi introduced a function to calculate the “Multivariate Environmental Similarity Surfaces” in R. Since then, the function has become part of the dismo package, which is a package maintained by Robert J. Hijmans and which offers a whole lot of functions for species distribution modelling.
The function calculates the MESS based on a point layer (the reference points) and a set of raster layers (the environmental data layers). It works great for smaller data sets, but you may run into trouble for very large data sets. So I needed to find a way to run this faster. And… I couldn’t. It is already a pretty neat piece of code, and I could not think of a better way of doing this in R. (
I am working on For an alternative to do this in GRASS, but more about that later: see here).
The maximum-entropy (Maxent) methods is one of the most widely used approaches for species habitat modelling. It has its own dedicated software, the Maxent software (written in java and therefore cross-platform). The software is easy to use and includes fairly a complete help file and tutorial. But things get better… Continue reading
R has some great packages for species distribution modelling. One of these packages is the dismo package.
Models objects created with one of the various distribution models available in dismo can be used to make prediction for any combination of values of the independent variables. To do this, you use the ‘predict‘ function. The predict function requires a model object and a RasterStack or dataframe with the independent variables.
So, what will be faster, a RasterStack or dataframe as input in the predict function? Continue reading
In R to create a contingency table of the counts of the combination of two variables, I would normally resort to table(). But how fast is it? A question that becomes more relevant when working on large tables and when you have to run it very often. As you will see in the examples below, it isn’t terribly fast and there are other ways to create cross tables faster. Continue reading