Importing WorldClim climate .bil datalayers in GRASS GIS II

I uploaded an update to the R script I posted earlier to import data downloaded from WorldClim into GRASS. The main change is that it unzips and imports one grid at a time into GRASS, thus requiring much less free space on your hard-disk.

It moreover has the option to import and convert the layer to the region settings of the mapset you are working in. Alternatively, you can import rasters in their original extend and resolution.

To run the script, start R from within GRASS GIS (on the command line, type R). In R, use the command source(“path-to-script-file”). This will create the function ‘import.wc.bil’.

This function has two arguments, the path to the folder with the downloaded zip files with WorldClim data and whether you want to use the extend and resolution of the file itself or that of the current mapset:

import.wc.bil(dr, region=”raster”)

‘dr’ is the path to the folder where you keep your downloaded data. Using the default region=”raster” will import your data as it is, any other choice will import the layers using the region settings of the Mapset.

Download script

Read the information section in the script file (open in your text editor) for additional information. 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!


7 thoughts on “Importing WorldClim climate .bil datalayers in GRASS GIS II

  1. Pingback: Importing WorldClim climate .bil datalayers in GRASS GIS « Ecostudies

  2. Pingback: R script to import WorldClim datalayers in GRASS GIS « Ecostudies

  3. Johannes


    I tried to use your R script to import a tile of the bioclim maps.
    I tried in R within the GRASS console
    > source(“/path/to/Import-worldclim-bil-layers_v14.r”)
    > import.wc.bil(“/path/to/bioclimdirectory”, region=”raster”)
    and then I get an error:

    ERROR: couldn’t find function “unzip”

    what is the problem?

    1. pvanb

      The scripts uses the function ‘unzip’ from the ‘utils’ package in R. I adapted the script (added ‘require unzip’ at the beginning of the script) so if you have the R package installed, it should automatically load it. If not, make sure to install the ‘utils’ package. Let me know if it doesn’t work.

  4. Johannes


    i checked my packages and it my R gui-package manager says there is a version of r.utils 1.1.1 installed. but still the same error…

    1. pvanb

      I don’t think ‘r.utils’ is the same package as ‘utils’ (is ‘unzip’ listed in the list of functions of the package?). If it is indeed not the same, install ‘utils’ using the package manager or using the command line: install.packages(‘utils’) and see if that solves your problem.

  5. Emma B

    I was wondering if you could help me. When I run the import.wc.bil script it gives me the error that there are no zip files in the folder that contains my downloads. Do you know what could be causing this? I’m running windows and GRASS 7.0.
    Thank you.

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