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!

About these ads

About pvanb

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).
This entry was posted in climate change, Data handling, Data sources, GIS, GRASS GIS, R computing environment and tagged , , , , . Bookmark the permalink.

6 Responses to 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 says:

    Hello,

    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?

    • pvanb says:

      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 says:

    hello,

    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…

    • pvanb says:

      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.

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