https://github.com/cran/FedData
Raw File
Tip revision: e7952465c2a8026d38c6dd7b03df7c458a87a808 authored by R. Kyle Bocinsky on 12 March 2018, 19:21:35 UTC
version 2.5.2
Tip revision: e795246
get_ghcn_daily.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/GHCN_FUNCTIONS.R
\name{get_ghcn_daily}
\alias{get_ghcn_daily}
\title{Download and crop the Global Historical Climate Network-Daily data.}
\usage{
get_ghcn_daily(template = NULL, label = NULL, elements = NULL,
  years = NULL, raw.dir = "./RAW/GHCN",
  extraction.dir = paste0("./EXTRACTIONS/", label, "/GHCN"),
  standardize = F, force.redo = F)
}
\arguments{
\item{template}{A Raster* or Spatial* object to serve 
as a template for cropping. Alternatively, a character vector providing GHCN station IDs. If missing, all stations
will be downloaded!}

\item{label}{A character string naming the study area.}

\item{elements}{A character vector of elements to extract.\cr
The five core elements are:\cr
PRCP = Precipitation (tenths of mm)\cr
SNOW = Snowfall (mm)\cr
SNWD = Snow depth (mm)\cr
TMAX = Maximum temperature (tenths of degrees C)\cr
TMIN = Minimum temperature (tenths of degrees C)\cr
\cr
The other elements are:\cr
  
ACMC = Average cloudiness midnight to midnight from 30-second 
ceilometer data (percent)\cr
ACMH = Average cloudiness midnight to midnight from 
manual observations (percent)\cr
ACSC = Average cloudiness sunrise to sunset from 30-second 
ceilometer data (percent)\cr
ACSH = Average cloudiness sunrise to sunset from manual 
observations (percent)\cr
AWDR = Average daily wind direction (degrees)\cr
AWND = Average daily wind speed (tenths of meters per second)\cr
DAEV = Number of days included in the multiday evaporation
total (MDEV)\cr
DAPR = Number of days included in the multiday precipitation 
total (MDPR)\cr
DASF = Number of days included in the multiday snowfall 
total (MDSF)\cr
DATN = Number of days included in the multiday minimum temperature 
(MDTN)\cr
DATX = Number of days included in the multiday maximum temperature 
(MDTX)\cr
DAWM = Number of days included in the multiday wind movement
(MDWM)\cr
DWPR = Number of days with non-zero precipitation included in 
multiday precipitation total (MDPR)\cr
EVAP = Evaporation of water from evaporation pan (tenths of mm)\cr
FMTM = Time of fastest mile or fastest 1-minute wind 
(hours and minutes, i.e., HHMM)\cr
FRGB = Base of frozen ground layer (cm)\cr
FRGT = Top of frozen ground layer (cm)\cr
FRTH = Thickness of frozen ground layer (cm)\cr
GAHT = Difference between river and gauge height (cm)\cr
MDEV = Multiday evaporation total (tenths of mm; use with DAEV)\cr
MDPR = Multiday precipitation total (tenths of mm; use with DAPR and 
                                     DWPR, if available)\cr
MDSF = Multiday snowfall total \cr
MDTN = Multiday minimum temperature (tenths of degrees C; use with DATN)\cr
MDTX = Multiday maximum temperature (tenths of degrees C; use with DATX)\cr
MDWM = Multiday wind movement (km)\cr
MNPN = Daily minimum temperature of water in an evaporation pan 
(tenths of degrees C)\cr
MXPN = Daily maximum temperature of water in an evaporation pan 
(tenths of degrees C)\cr
PGTM = Peak gust time (hours and minutes, i.e., HHMM)\cr
PSUN = Daily percent of possible sunshine (percent)\cr
SN*# = Minimum soil temperature (tenths of degrees C)
  where * corresponds to a code
for ground cover and # corresponds to a code for soil 
depth.\cr
\cr
Ground cover codes include the following:\cr
0 = unknown\cr
1 = grass\cr
2 = fallow\cr
3 = bare ground\cr
4 = brome grass\cr
5 = sod\cr
6 = straw multch\cr
7 = grass muck\cr
8 = bare muck\cr
\cr
Depth codes include the following:\cr
1 = 5 cm\cr
2 = 10 cm\cr
3 = 20 cm\cr
4 = 50 cm\cr
5 = 100 cm\cr
6 = 150 cm\cr
7 = 180 cm\cr
\cr
SX*# = Maximum soil temperature (tenths of degrees C) 
  where * corresponds to a code for ground cover 
and # corresponds to a code for soil depth.\cr 
See SN*# for ground cover and depth codes. \cr
TAVG = Average temperature (tenths of degrees C)
[Note that TAVG from source 'S' corresponds
to an average for the period ending at
2400 UTC rather than local midnight]\cr
THIC = Thickness of ice on water (tenths of mm)\cr
TOBS = Temperature at the time of observation (tenths of degrees C)\cr
TSUN = Daily total sunshine (minutes)\cr
WDF1 = Direction of fastest 1-minute wind (degrees)\cr
WDF2 = Direction of fastest 2-minute wind (degrees)\cr
WDF5 = Direction of fastest 5-second wind (degrees)\cr
WDFG = Direction of peak wind gust (degrees)\cr
WDFI = Direction of highest instantaneous wind (degrees)\cr
WDFM = Fastest mile wind direction (degrees)\cr
WDMV = 24-hour wind movement (km)\cr
WESD = Water equivalent of snow on the ground (tenths of mm)\cr
WESF = Water equivalent of snowfall (tenths of mm)\cr
WSF1 = Fastest 1-minute wind speed (tenths of meters per second)\cr
WSF2 = Fastest 2-minute wind speed (tenths of meters per second)\cr
WSF5 = Fastest 5-second wind speed (tenths of meters per second)\cr
WSFG = Peak gust wind speed (tenths of meters per second)\cr
WSFI = Highest instantaneous wind speed (tenths of meters per second)\cr
WSFM = Fastest mile wind speed (tenths of meters per second)\cr
WT** = Weather Type where ** has one of the following values:\cr
  \cr
01 = Fog, ice fog, or freezing fog (may include heavy fog)\cr
02 = Heavy fog or heaving freezing fog (not always 
                                        distinguished from fog)\cr
03 = Thunder\cr
04 = Ice pellets, sleet, snow pellets, or small hail \cr
05 = Hail (may include small hail)\cr
06 = Glaze or rime \cr
07 = Dust, volcanic ash, blowing dust, blowing sand, or 
blowing obstruction\cr
08 = Smoke or haze \cr
09 = Blowing or drifting snow\cr
10 = Tornado, waterspout, or funnel cloud \cr
11 = High or damaging winds\cr
12 = Blowing spray\cr
13 = Mist\cr
14 = Drizzle\cr
15 = Freezing drizzle \cr
16 = Rain (may include freezing rain, drizzle, and freezing drizzle) \cr
17 = Freezing rain \cr
18 = Snow, snow pellets, snow grains, or ice crystals\cr
19 = Unknown source of precipitation \cr
21 = Ground fog \cr
22 = Ice fog or freezing fog\cr
\cr
WV** = Weather in the Vicinity where ** has one of the following 
values:\cr
01 = Fog, ice fog, or freezing fog (may include heavy fog)\cr
03 = Thunder\cr
07 = Ash, dust, sand, or other blowing obstruction\cr
18 = Snow or ice crystals\cr
20 = Rain or snow shower}

\item{years}{A numeric vector indicating which years to get.}

\item{raw.dir}{A character string indicating where raw downloaded files should be put.
The directory will be created if missing. Defaults to './RAW/GHCN/'.}

\item{extraction.dir}{A character string indicating where the extracted and cropped GHCN shapefiles should be put.
The directory will be created if missing. Defaults to './EXTRACTIONS/GHCN/'.}

\item{standardize}{Select only common year/month/day? Defaults to FALSE.}

\item{force.redo}{If an extraction for this template and label already exists, should a new one be created? Defaults to FALSE.}
}
\value{
A named list containing the 'spatial' and 'tabular' data.
}
\description{
\code{get_ghcn_daily} returns a named list of length 2: 
\enumerate{
\item 'spatial': A \code{SpatialPointsDataFrame} of the locations of GHCN weather stations 
in the template, and 
\item 'tabular': A named list of \code{\link{data.frame}s} with the daily weather data for each station.
The name of each list item is the station ID.
}
}
\examples{
\dontrun{
# Extract data for the Village Ecodynamics Project 'VEPIIN' study area:
# http://village.anth.wsu.edu
vepPolygon <- polygon_from_extent(raster::extent(672800,740000,4102000,4170000), 
     proj4string='+proj=utm +datum=NAD83 +zone=12')

# Get the daily GHCN data (GLOBAL)
# Returns a list: the first element is the spatial locations of stations,
# and the second is a list of the stations and their daily data
GHCN.prcp <- get_ghcn_daily(template=vepPolygon, label='VEPIIN', elements=c('prcp'))

# Plot the VEP polygon
plot(vepPolygon)

# Plot the spatial locations
plot(GHCN.prcp$spatial, pch=1, add=T)
legend('bottomleft', pch=1, legend='GHCN Precipitation Records')

# Elements for which you require the same data
# (i.e., minimum and maximum temperature for the same days)
# can be standardized using standardize==T
GHCN.temp <- get_ghcn_daily(template=vepPolygon, 
     label='VEPIIN', 
     elements=c('tmin','tmax'), 
     standardize=T)

# Plot the VEP polygon
plot(vepPolygon)

# Plot the spatial locations
plot(GHCN.temp$spatial, pch=1, add=T)
legend('bottomleft', pch=1, legend='GHCN Temperature Records')
}
}
back to top