Adds circle markers to a leaflet map representing salinity measurements, with popups showing the salinity value and site information.
Usage
add_salinity_points(
map,
data,
palette = "YlGnBu",
domain = c(0, 40),
color_function = NULL
)Arguments
- map
A leaflet map object
- 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 for colors (default:
c(0, 40))- color_function
Optional pre-created color function (overrides palette and domain if provided)
Examples
# generate salinity data to map
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)`
# create base map
my_map <- create_mssnd_basemap()
# Add points, using default color palette
my_map |>
add_salinity_points(to_map)
# Add points and legend, using default color palette
my_map |>
add_salinity_points(to_map) |>
add_salinity_legend()
# Add points and legend, using non-default existing palette
my_map |>
add_salinity_points(to_map, palette = "Spectral") |>
add_salinity_legend(palette = "Spectral")
# Add points and legend, using custom domain
my_map |>
add_salinity_points(to_map, domain = c(5, 35)) |>
add_salinity_legend(domain = c(5, 35))
#> Warning: Some values were outside the color scale and will be treated as NA
#> Warning: Some values were outside the color scale and will be treated as NA