GRASS 7.0 is out, but the development continues unabated

Just a thumbs-up for the developers of GRASS GIS, who evidently do not rest on their laurels since their release of GRASS GIS 7.0. Below one of those more visible new features in the GRASS GIS development version which make live just that much easier.

nice new feature
A really welcome addition to the drop-down menu for selection of raster or vector layers. It now shows the open maps under a separate header.

A map with the number of mammal species based on IUCN redlist range maps

I am looking at species richness and number of threatened species across the landscape in eastern Africa and will explain briefly how you can create a map based on data from the IUCN Red List of Threatened Species spatial data set. From this site you can download expert validated range maps of species belonging to the taxonomic groups terrestrial mammals, reptiles and amphibians.

The maps are available as shapefiles. Not as one layer per species, but one (very) large shapefile that contains all the distribution maps of that group. If you don’t need it for the whole world, the first step you probably want to do is to clip the layer to your area of interest (there are various tools available in QGIS or you can do this from the command line using ogr2ogr.

If you import these shapefiles in GRASS GIS, they will be broken up into unique polygons. This is because GRASS GIS is a topological GIS as explained in more detail here, and therefore does not allow overlapping polygons. So, if you import the shapefile with terrestrial mammals for east Africa, you get something like this:

Vector distribution maps of the terrestrial mammals in east Africa from the IUCN red list
Vector distribution maps of the terrestrial mammals in east Africa from the IUCN red list

Already one can see some interesting patterns there, and the next step is to compute a map with the number of species. The number of species at any given location is of course the same as the number of overlapping polygons at that location. But how do we get that number? And didn’t I just wrote that there are no overlapping polygons in GRASS GIS?

First a little bit of background about how GRASS GIS handles vector layers and attribute tables. Each polygon (unique feature) will have one or more records in the attribute table. The map features (geometries) are linked to their attributes via what is called a Layer in GRASS GIS.

text5880As explained here, a vector layer can be linked to more than one attribute tables (note, it doesn’t need to be linked to a table), which is really neatly illustrated in Figure 1 on this page. If you import a vector layer with overlapping polygons, you will get a vector map with two layers. One that connects the polygons with the attribute table as explained above, and a layer 2 with categories that represent for each feature (polygon) the number of overlapping polygons in the original vector layer (with no linked to an attribute table).

This means GRASS is already doing automatically what I was asking for; counting the number species ( = number of overlapping polygons). Only, we don’t have those values in an attribute table so we cannot create a species-count map directly. The arguably easiest way is to convert the vector layer to a raster layer, whereby the raster values will be based on the values of Layer 2.

Convert the vector layer to a raster layer
Convert the vector layer to a raster layer. Use as source of raster values ‘cat’

You do this using the command, directly from the command line, or using the GUI like above (menu: vector: map type conversion: vector to raster). Make sure to select as source of raster values ‘cat’. And under the optional tab, select layer = 2 (layer number of name option).

Convert a vector to raster, using the cat value of layer 2
Convert a vector to raster, using the cat value of layer 2, which in this case represent the number of overlapping polygons in the original shapefile that we imported.

Next, select a nice colour palette for your raster layer and you’ll have your map depicting the number of species listed (and mapped) for the IUCN red list.

Count of terrestrial mammal species. Based on range maps from the IUCN red list.
Count of terrestrial mammal species. Based on range maps from the IUCN red list.

This is only a first step, and there is much more you can get out of this data. For example, you can combine the maps with information species current threat status, population size and species habitat preference; all available from the IUCN red list. See for example this nice blog post about Assessing habitat specialization using IUCN data.

Importing GLCF MODIS woody plant cover

The data set

The Global Land Cover Facility offers, amongst many other data sets, the MODIS Vegetation Continuous Fields data set for download. These are layers that contain proportional estimates for vegetative cover types (woody vegetation, herbaceous vegetation, and bare ground). As such they are very suitable depict areas of heterogeneous land cover.

Their MODIS products differ from DAAC editions by coming in GeoTIFF format, geographic coordinates, WGS84 datum, and a tiling system designed to fit well with Landsat imagery. Currently the collection 5 is available, which contains proportional estimates for woody cover vegetation for the years 2000 to 2010. It can be downloaded as tiles (195 in total) via a ftp server.

Below I’ll provide an example Continue reading Importing GLCF MODIS woody plant cover

Importing data in GRASS GIS – an example


ISRIC, Earth Institute, Columbia University, World Agroforestry Centre (ICRAF) and the International Center for Tropical Agriculture (CIAT) have recently released a new data set of raster layers with various predicted soil properties. This data set is referred to as the “AfSoilGrids250m” data set. It supersedes the SoilGrids1km data set and comes at a resolution of 250 meter. The AfSoilGrids250m data (GeoTIFFs) are available for download under the Attribution 4.0 International (CC BY 4.0) license. See this page for download information.

In this post I’ll show you how you can import this data set in a GRASS GIS database. Continue reading Importing data in GRASS GIS – an example

Update of r.mess to work in GRASS 7

A while back I wrote a GRASS GIS addon to calculate the Multivariate Environmental Similarity index (MES; see below for a short description). The addon was written as a shell script and R script and only runs on GRASS GIS 6.

I finally got around rewriting the addon in Python. This should make it easier to install (using the g.extension function) and it does not depend on R any more. You can install the addon from the g.extension menu or you can go here. Continue reading Update of r.mess to work in GRASS 7

GRASS GIS 7.0 beta 4 released

The 4th beta release of GRASS GIS 7.0 is available for download. This is the last step before the planned release candidate (RC1), so a very good time to take it for a test run.

The most important changes in beta 4 are a major effort to standardize all parameter and flag names. This will bring a better and more consistent user experience. For more details and the download links, to to

Access R from GRASS GIS on Windows

Since I have switch from Windows to Linux, many years ago, things have started to look a lot brighter for those wanting to use GRASS on Windows. I won’t switch back to Windows any time soon, but I recently had to install WinGRASS for somebody else. And it was a whole lot easier than I had feared (or even hoped).

But there is one thing I couldn’t immediately figure out; how to run R from within GRASS. I should add that I installed GRASS using the OSGEO4W installer. When installing GRASS using the stand alone installer, access to R from the GRASS command line should work out-of-the-box (see comment from Helmut in the comment section below).

After a bit of trial and error, I came up with the steps below. It involves editing a file to tell GRASS where to look for executables. In the example below I am adding the path to the R and rstudio executables to this file. Having done that, I can now type R.exe or rstudio.exe on the GRASS command line to open these programs. Continue reading Access R from GRASS GIS on Windows