dlGsodStations: Download (and extract) GSOD data

View source: R/dlGsodStations.R

dlGsodStationsR Documentation

Download (and extract) GSOD data

Description

Download (and extract) data from a GSOD station based on its unique USAF code.

Usage

dlGsodStations(
  usaf,
  start_year = NA,
  end_year = NA,
  dsn = ".",
  unzip = FALSE,
  rm_gz = FALSE,
  ...
)

Arguments

usaf

Numeric. A unique USAF station code. It can either be manually determined from built-in gsodstations, or retrieved from spatial subsetting (see stationFromCoords, stationFromExtent).

start_year

Numeric. The desired year to start data acquisition. If not supplied, download starts from the first year of measurement.

end_year

Numeric. The desired year to stop data acquisition. If not supplied, download stops at the last year of measurement.

dsn

Character, default is the current working directory. Destination folder for data download.

unzip

Logical, default is FALSE. If TRUE, *.gz files are unpacked and merged after download.

rm_gz

Logical, default is FALSE. If TRUE, *.gz files are removed after extraction. If unzip = FALSE, this argument is ignored.

...

Additional arguments passed to gzGsodStations.

Value

A vector of *.gz filenames, or an object of class data.frame if unzip = TRUE.

Author(s)

Florian Detsch

Examples

## Not run: 
moshi = subset(
  gsodstations
  , `STATION NAME` == "MOSHI"
)

# download data from moshi, tanzania, from 1990 to 1995
gsod_moshi = dlGsodStations(
  usaf = moshi$USAF
  , start_year = 1990
  , end_year = 1995
  , dsn = tempdir()
  , unzip = TRUE
)

# plot temperature data
plot(
  TEMP ~ YEARMODA
  , data = gsod_moshi
  , type = "l"
)

## End(Not run)


environmentalinformatics-marburg/GSODTools documentation built on Jan. 5, 2024, 12:19 a.m.