Archive

Posts Tagged ‘global climate data’

Import worldclim data into GRASS

This post is about how to import worldclim data sets into a GRASS project.

WorldClim – Global Climate Data WorldClim is a set of global climate layers (climate grids) with a spatial resolution of about 1 square kilometer. The data can be used for mapping and spatial modeling in a GIS or with other computer programs.
http://www.worldclim.org/

First you need to create a location using the EPSG code corrresponding to the worldclim data. It is 4326. You can find a list of the EPSG codes at http://spatialreference.org/

Once the location has been created you can launch GRASS with the location and import worldclim data sets. Worldclim offers different resolutions and you have to choose one of them. Then, define the g.region in GRASS using the selected resolution. For instance, we want data at a resolution of 00:02:30.
In GRASS type:

g.region n=90N s=90S e=180E w=180W res=00:02:30

This matches with the extent of the worldclim data and the desired resolution.

The last step is pretty straightforward. Select the directory where the worldclim data have been downloaded.
For instance:

cd /home/rossi/data/worldclim/ 

Then import the data (here we import the Altitude layer)

r.in.bin -s input=alt.bil output=altitude bytes=2 north=90 south=-60 east=180 west=-180 rows=3600 cols=8640 anull=-9999 

Note that the number of columns and rows as well as the east, west, north and south limits are given in the *.bil file available in the download from http://www.worldclim.org.

It is convenient to import automatically a set of layers using a loop :

for i in $(seq 1 19)
do
r.in.bin -s input=bio$i.bil output=bio$i bytes=2 north=90 south=-60 east=180 west=-180 rows=3600 cols=8640 anull=-9999
done

In that example, we have imported the 19 layers of the BIOCLIM variables using a loop and the GRASS function r.in.bin

Now the worldclim data are available within our GRASS location. These raster layers can be used visualisation, analyses and modelling with GRASS but also using R (see the post “Playing with R within a GRASS environment” from this blog).

Have fun!