gzGsodStations: Extract and merge downloaded GSOD data

View source: R/gzGsodStations.R

gzGsodStationsR Documentation

Extract and merge downloaded GSOD data

Description

Extract and merge previously downloaded GSOD data based on a unique USAF station code and a supplied temporal range.

Usage

gzGsodStations(
  usaf,
  dsn = ".",
  start_year = NULL,
  end_year = NULL,
  save_output = 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).

dsn

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

start_year

Numeric. The desired year to start data extraction and concatenation. If not supplied, all files in dsn will be considered.

end_year

Numeric. The desired year to stop data extraction and concatenation. If not supplied, all files in dsn will be considered.

save_output

Logical, default is FALSE. If TRUE, a local copy of the concatenated GSOD data will be created based on the settings provided to ...

rm_gz

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

...

Additional arguments passed to write.table.

Value

An object of class data.frame.

Author(s)

Florian Detsch

Examples

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

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

# Download data from Moshi, Tanzania, from 1990 to 1995
gsod_moshi <- gzGsodStations(usaf = moshi$USAF, 
                             start_year = 1990, end_year = 1995, 
                             dsn = tempdir(),
                             save_output = TRUE, 
                             file = file.path(tempdir(), "moshi_1990_1995.csv"), 
                             row.names = FALSE)

# Plot temperature data (but: time series not continuous!)
plot(gsod_moshi$TEMP, type = "l")

## End(Not run)


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