R script to import WorldClim datalayers in GRASS GIS

As I wrote before, you can download monthly climate data layers (rainfall, mean minimum and maximum temperature of the coldest and warmest month respectively) from WorldClim for current and future climate conditions. The latter can only be downloaded in generic grid (raster) format (.bil). Moreover, monthly data layers are compressed in one zip file.

I also posted a small R script that unzips the zip files with monthly data layers downloaded from WorldClim (.bil format) and imports it your current GRASS GIS Location and Mapset. It also corrects erroneous grid cell values as discussed in that post.

I updated the script, hopefully making it easier to use. You can download it here [Update, I made a new, hopefully improved version, see this post]. First, you need to run R within GRASS GIS (type R in the GRASS GIS terminal. Next, load the script in R using:

> source(“path-and-file-name-of-the-script”)

This will create the function import.wc.bil in R. The function only requires one argument; the path to the folder with the zip file(s) with climate data layers. E.g.,

> import.wc.bil(“/home/yourname/Documents”)

It will unzip all zip files in the folder /home/yourname/Documents/ and subsequently import the .bil files to the current GRASS mapset. Read the information section in the script file (open in your text editor) for additional information.

Download script here or go here for a newer version —

I am not sure it will work in Windows, let me know if not. And as usual, no guarantees, use the script at your own risk!


About these ads

Published by


I am a tropical forest ecologist with a focus on spatial and temporal patterns and processes at population and ecosystem level. I am furthermore very interested in issues related to conservation and sustainable use of biodiversity and natural resources under current and future climates. I have worked in the Middle East (Syria and Lebanon) and South America (Brazil) and in Eastern Africa (Kenya).

2 thoughts on “R script to import WorldClim datalayers in GRASS GIS”

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s