Integrating Maxent, R and GRASS GIS

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…

There is also the option to run Maxent via R, using the dismo package. Dismo basically provides a R command line interface to the Maxent software. This makes it possible to directly ‘capture’ the maxent result model in R. You can use these to evaluate the results and combine them with other R functionality.

Dismo uses the raster package in R to deal with (potentially large) raster layers. This package has greatly enhanced the spatial capabilities of R. However, in my experience it is still a bit slow when handling very large raster layers (much will of course depend on your hardware, especially the amount of RAM). Therefore, when dealing with very large raster layers, I prefer to use GRASS GIS.

Although it isn’t very difficult to create in- and output files for use in Maxent, it takes time. But it has become much easier with the GRASS add-ons by Stefan Blumentrath from the Norwegian Institute for Nature Research (NINA). He created two packages, r.out.maxent and r.maxent.lambdas, that makes it much easier to work with Maxent. You can find both on the GRASS add-on wiki.

The first add-on, r.out.maxent, allows you to produce a set of SWD files as input to Maxent (background SWD and optionally a species SWD file). The other function, r.maxent.lambdas, allows you to compute  raw and/or logistic prediction maps directly in GRASS GIS, using the MaxEnt lambdas files as input.

You can of course combine the different tools into a work flow that works best for you. For example you can use GRASS to deal with the raster layers and create input data, Maxent to create the models (possibly via R), GRASS GIS again to create probability distribution maps, and R and GRASS GIS to analyze the results.


5 thoughts on “Integrating Maxent, R and GRASS GIS

  1. Another software alternative might be the OpenModeller Suite (, which comes with many useful models (Maxent, ENFA, etc…).
    It is also available for operating systems with linux installed. In previous times it was also possible to integrate open modeller into qgis, however until now i couldn’t get it to work.

    1. pvanb

      Check if you need to; the r.out.maxent_swd script lets you create swd files for more then one species at once. Also, it is fairly easy to run a loop from the (GRASS) command line.

      But if you need: You can run any GRASS function from R. You need to start R from within GRASS to do that. Having done that, you can use a system call (system(“your grass function call”)) or the execGRASS() function from the spgrass6 package to run GRASS commands. From there is is simple to put those system calls or execGRASS() calls in a loop.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s