Learn R Programming

climenv (version 1.0.0)

worldclim: Download WorldClim climate data

Description

worldclim() downloads the WorldClim V2.1 climate data for 1970–2000. This includes monthly climate data for minimum, mean, and maximum temperature and precipitation at a resolution of 0.5 minutes of a degree. This function uses the geodata to download the worldclim tiles.

Usage

worldclim(output_dir, location, var = "all", ...)

Value

worldclim() is called for its side effects and returns NULL. Creates four subfolders named prec, tmax, tmin and tmean. Each folder contains 12 GeoTiff (.tif) files, one for each month of the year for the time period 1970–2000. Each of the files are downloaded at a spatial resolution of 0.5 minutes of a degree. The precipitation folder contains average monthly precipitation (mm). The tmax folder contains maximum monthly temperature. The tmin folder contains minimum monthly temperature. The tmean folder contains the average monthly temperature. Temperature values are reported in °C.

Arguments

output_dir

Character (e.g., "../Desktop/chelsa"). Pathway to where the data will be stored.

location

A "sp", "sf" polygon or point object. See sf::st_polygon to make polygons and sf::st_as_sf to make point objects.

var, ...

Arguments to download.file() to control file download. .

Author

James L. Tsakalos and Martin R. Smith

References

Fick, S.E. & Hijmans, R.J. (2017). WorldClim 2: new 1km spatial resolution climate surfaces for global land areas. International Journal of Climatology. 37, 4302–4315. tools:::Rd_expr_doi("10.1002/joc.5086")

See Also

Downloading from CHELSA chelsa() or a more convenient function for downloading other climate and elevation data ce_download().

Examples

Run this code
# \donttest{
# Download time will depend on the size of the area you wish to access
# climate data for and your internet connection speed.

# Make a polygon file
regents <- sf::st_polygon(
  list(
    cbind(
      "lon" = c(51.537, 51.525, 51.523, 51.530, 51.534, 51.537),
      "lat" = c(-0.150, -0.145, -0.156, -0.167, -0.163, -0.150)
    )
  )
)

# Create temporary file
temp_path <- tempfile()

# Download the WorldClim data
worldclim(
  output_dir = temp_path,
  location = regents
)

# Reset user options
unlink(file.path(temp_path))

# }

Run the code above in your browser using DataLab