Identifies the n^th nearest CDEC gage to a lat/lon of interest. This function requires metadata of all CDEC stations of interest. By default, all CDEC stations are used.
Arguments
- df
A data frame that contains at least the lat/lon of station(s) of interest, named as
lat
andlon
.- n
A number reflecting the desired relative distance of the CDEC gage from the lat/lon of interest. n=1 means return the closest gage, n=2 means return the second closest gage, etc. n should be an integer or should otherwise be convertible to an integer.
- cdecGPS
A data frame containing the GPS coordinates of the CDEC gages of interest, as
lat
andlon
.- cdecMetadata
A data frame containing the metadata table of the CDEC gages of interest. This table must match the format provided by the DWR website. It is recommended to use
pullMetadataCDEC()
to get this data.- variable
The water quality variable of interest. Currently only supports water temperature as
temp
, turbidity asturbidity
, and electro-conductivity asec
. This defaults to water temperature.- waterColumn
Where in the water column should the variable of interest be prioritized? Supports only
top
andbottom
, defaulting totop
. For now, top data will be used in the calculation even if you ask for bottom data.
Value
A data frame of the metadata of the n^th closest CDEC station to your point of interest that has data for the variable of interest.
Examples
if (FALSE) { # \dontrun{
df <- data.frame(station = "306", lat = 38.00064, lon = -122.4136)
calcNthNearestCDEC(df)
} # }