This function takes information of where and when a set of environmental samples were collected and retrieves daily river discharge data from the nearest river (\(m^3/s\)) for those locations and times. Data come from the Open-Meteo Global Flood API (https://open-meteo.com/en/docs/flood-api) via the openmeteo R package.

get_river_discharge_data(lon, lat, dates)

Arguments

lon

A numeric vector giving the longitude of the sampling sites in Decimal Degrees.

lat

A numeric vector giving the latitude of the sampling sites in Decimal Degrees.

dates

A character or date vector of dates giving the date when each sample was collected (format is YYYY-MM-DD)

Value

data.frame

Examples

if (FALSE) {

d <- get_river_discharge_data(lon = c(-54.9857, -52.9857),
                              lat = c(-10.9094, -25.8756),
                              dates = c("2020-06-01", "2020-10-31"))

head(d)

ggplot2::ggplot(d, aes(x = date)) +
     geom_line(aes(y = daily_river_discharge)) +
     facet_grid(rows=vars(id)) +
     labs(x="", y = "Local River Discharge (m^3/s)") +
     theme_bw() +
     theme(legend.position = 'bottom',
           legend.title = element_blank())

}