Learn R Programming

climenv (version 1.0.0)

ce_download: Download climate and elevation data

Description

ce_download() brings together the worldclim(), chelsa() and elev() functions to streamline downloading.

Usage

ce_download(
  output_dir,
  c_source = "WorldClim",
  e_source = "mapzen",
  var = "all",
  location,
  ...
)

Value

See documentation from chelsa(), worldclim() and elev().

Arguments

output_dir

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

c_source

Character (e.g., "CHELSA or WorldClim"). Indicating the climate data source.

e_source

Character (e.g., mapzen or geodata). Indicating the elevation data source.

var

Character. If supplied will download a subset of the climate data. Must be one of "all" (default), "prec", "tmax", "tmin" or "tmean" to download the corresponding climate data.

location

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

...

Arguments to control a download from the Internet download.file().

Author

James L. Tsakalos and Martin R. Smith

See Also

The underlying functions chelsa(), worldclim() and elev().

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 output directory
temp_path <- tempdir()

# Run the download function
ce_download(
  output_dir = temp_path,
  location = regents
)

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

# }

Run the code above in your browser using DataLab