Create interactive salinity map for Mississippi Sound data
Source:R/map_mssnd_salinity.R
map_mssnd_salinity.RdCreates an interactive leaflet map displaying salinity data from USGS stations
in the Mississippi Sound area. This is a convenience function that combines
the create_mssnd_basemap(), add_salinity_points(), and add_salinity_legend() functions
in a single call.
Usage
map_mssnd_salinity(data, palette = "YlGnBu", domain = c(0, 40))Arguments
- data
A data frame containing salinity data for a single date, generally created by joining the
$dailyand$siteInfocomponents of output from theget_mssnd_data()function, then filtered to a single date. Must include the following columns:dec_lon_va: Decimal longitude of stationdec_lat_va: Decimal latitude of stationsal_mean: Daily mean salinity in parts per thousand (ppt)clean_nm: Station namesite_no: USGS site number
- palette
Character string specifying the color palette name (default:
"YlGnBu")- domain
Numeric vector of length 2 specifying the domain range (default:
c(0, 40))
Value
A leaflet map object centered on the Mississippi Sound area (approximately 30.25°N, 89.15°W) with station markers colored by salinity values.
Note
This function is currently specific to USGS station data format. The input should represent data from a single date.
Examples
# Using the included mssnd_salinity example dataset
to_map <- dplyr::left_join(mssnd_salinity$daily, mssnd_salinity$siteInfo) |>
dplyr::filter(date == as.Date("2023-06-01"))
#> Joining with `by = join_by(site_no)`
map_mssnd_salinity(to_map)
# Same example dataset, but a date where only 2 stations have a daily average
to_map <- dplyr::left_join(mssnd_salinity$daily, mssnd_salinity$siteInfo) |>
dplyr::filter(date == as.Date("2020-06-01"))
#> Joining with `by = join_by(site_no)`
map_mssnd_salinity(to_map)