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

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

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().

Value

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

See also

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

Author

James L. Tsakalos and Martin R. Smith

Examples

# \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
)
#> "Writing to: /tmp/RtmpDLXUpX"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_01.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_02.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_03.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_04.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_05.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_06.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_07.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_08.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_09.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_10.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_11.tif"
#> "  File: /tmp/RtmpDLXUpX/prec/wc2.1_30s_prec_12.tif"
#> "Writing to: /tmp/RtmpDLXUpX"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_01.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_02.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_03.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_04.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_05.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_06.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_07.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_08.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_09.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_10.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_11.tif"
#> "  File: /tmp/RtmpDLXUpX/tmax/wc2.1_30s_tmax_12.tif"
#> "Writing to: /tmp/RtmpDLXUpX"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_01.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_02.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_03.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_04.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_05.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_06.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_07.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_08.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_09.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_10.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_11.tif"
#> "  File: /tmp/RtmpDLXUpX/tmin/wc2.1_30s_tmin_12.tif"
#> "Writing to: /tmp/RtmpDLXUpX"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_01.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_02.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_03.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_04.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_05.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_06.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_07.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_08.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_09.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_10.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_11.tif"
#> "  File: /tmp/RtmpDLXUpX/tavg/wc2.1_30s_tavg_12.tif"
#> Warning: Coordinate reference system not specified; assuming WGS84
#> Mosaicing & Projecting

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

# }