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 v.to.rast 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

Introduction

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

Exporting your GRASS raster using r.out.gdal? Check the createopt options!

GRASS GIS can export your raster layer in most common (and quite a few less common) data formats using the r.out.gdal function (menu: file – export raster map – common raster formats). Exporting is so simple that you may forget that depending on the output format there are different options to optimise your output raster layer. Continue reading Exporting your GRASS raster using r.out.gdal? Check the createopt options!

Import MODIS data in GRASS using r.in.gdal

NASA offers access to its MODIS and ASTER data sets through Reverb|Echo. The data comes in HDF format and uses the Sinusoidal grid tiling system. If your gdal is compiled with HDF4 support (use ./configure –with-hdf4), you can use gdal, or any software that uses gdal, to open the downloaded MODIS tiles directly. For example in QGIS as explained here or in GRASS GIS.

In GRASS you can use the r.in.gdal function. Continue reading Import MODIS data in GRASS using r.in.gdal

Extracting lines ending with specific character using sed or grep

A quick note (to myself mostly) about how to extract lines from a text file that end with a specific set of characters. In Linux, you can very easily do this using ‘grep’ or ‘sed’. But, first a little bit of background. Continue reading Extracting lines ending with specific character using sed or grep