diff --git a/DESCRIPTION b/DESCRIPTION index ca76697e..bd1eed7b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -52,6 +52,7 @@ Suggests: covr (>= 3.5.1), DBI (>= 1.1.1), leaflet (>= 2.0.4.1), + leaflet.extras (>= 1.0.0), leaftime (>= 0.2.0), geojsonio (>= 0.9.4), geojsonlint (>= 0.4.0), diff --git a/NAMESPACE b/NAMESPACE index 6c869683..16a7c2a0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -83,6 +83,7 @@ export(map_nests) export(map_sv_odkc) export(map_tracks) export(map_tracks_odkc) +export(map_wastd) export(nest_disturbance_by_season_odkc) export(nesting_type_by_area_season_age_species) export(nesting_type_by_area_season_age_species_odkc) diff --git a/R/map_dist.R b/R/map_dist.R index 14cfe206..3b4d07a8 100644 --- a/R/map_dist.R +++ b/R/map_dist.R @@ -42,9 +42,12 @@ map_dist <- function(dist, # Base map # l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds() + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() # ---------------------------------------------------------------------------# # Disturbances by cause @@ -101,7 +104,7 @@ Edit record in WAStD

l %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = overlay_names, options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_dist_odkc.R b/R/map_dist_odkc.R index c78b4a08..b510460f 100644 --- a/R/map_dist_odkc.R +++ b/R/map_dist_odkc.R @@ -41,9 +41,12 @@ map_dist_odkc <- function(dist, co <- if (cluster == TRUE) leaflet::markerClusterOptions() else NULL l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds() + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() # ---------------------------------------------------------------------------# # Disturbances by cause @@ -168,7 +171,7 @@ src="{photo_disturbance %||% ""}"> } } %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = overlay_names, options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_mwi.R b/R/map_mwi.R index c664b4e4..30604e2e 100644 --- a/R/map_mwi.R +++ b/R/map_mwi.R @@ -29,9 +29,12 @@ map_mwi <- function(data, url <- sub("/$", "", wastd_url) l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds() + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() if (!is.null(data) && nrow(data) > 0) { @@ -107,7 +110,7 @@ href="{url}{absolute_admin_url}">Edit on WAStD

} } %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = overlay_names, options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_mwi_odkc.R b/R/map_mwi_odkc.R index 59534945..0f8138d7 100644 --- a/R/map_mwi_odkc.R +++ b/R/map_mwi_odkc.R @@ -35,9 +35,12 @@ map_mwi_odkc <- function(data, overlay_names <- c() l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds() + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() if (!is.null(data) && nrow(data) > 0) { @@ -136,7 +139,7 @@ Samples taken: {checks_samples_taken}
} } %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = overlay_names, options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_nests.R b/R/map_nests.R index bb831ed8..e3f0d3da 100644 --- a/R/map_nests.R +++ b/R/map_nests.R @@ -26,9 +26,12 @@ map_nests <- function(data, url <- sub("/$", "", wastd_url) l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds() %>% + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() %>% leaflet::addAwesomeMarkers( data = data, lng = ~encounter_longitude, @@ -73,7 +76,7 @@ href="{url}{encounter_absolute_admin_url}">Edit on WAStD

clusterOptions = co ) %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = c("Nests"), options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_sitevisit.R b/R/map_sitevisit.R index a9eb2bfa..85a30d2c 100644 --- a/R/map_sitevisit.R +++ b/R/map_sitevisit.R @@ -33,9 +33,12 @@ map_sv_odkc <- function(svs, co <- if (cluster == TRUE) leaflet::markerClusterOptions() else NULL l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds() %>% + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() %>% # Site Visit Start leaflet::addAwesomeMarkers( data = svs, @@ -109,7 +112,7 @@ map_sv_odkc <- function(svs, label = ~site_name ) %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = c("Site Visit Start", "Site Visit End"), options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_tracks.R b/R/map_tracks.R index f8dfa33c..f51562c2 100644 --- a/R/map_tracks.R +++ b/R/map_tracks.R @@ -34,9 +34,12 @@ map_tracks <- function(tracks, if (!("name" %in% names(tracks))) tracks <- dplyr::mutate(tracks, name = "") l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds(.) %>% + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() %>% { if (ts == TRUE) { leaftime::addTimeline(., @@ -123,7 +126,7 @@ href="{url}{absolute_admin_url}">Edit on WAStD

} } %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = overlay_names, options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_tracks_odkc.R b/R/map_tracks_odkc.R index e296ded8..5e068dcd 100644 --- a/R/map_tracks_odkc.R +++ b/R/map_tracks_odkc.R @@ -39,9 +39,12 @@ map_tracks_odkc <- function(tracks, } l <- leaflet::leaflet(width = 800, height = 600) %>% - leaflet::addProviderTiles("Esri.WorldImagery", group = "Aerial") %>% - leaflet::addProviderTiles("OpenStreetMap.Mapnik", group = "Place names") %>% - leaflet::clearBounds(.) %>% + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35)) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() %>% { if (ts == TRUE) { leaftime::addTimeline( @@ -133,7 +136,7 @@ map_tracks_odkc <- function(tracks, } } %>% leaflet::addLayersControl( - baseGroups = c("Aerial", "Place names"), + baseGroups = c("Basemap"), overlayGroups = overlay_names, options = leaflet::layersControlOptions(collapsed = FALSE) ) diff --git a/R/map_wastd.R b/R/map_wastd.R new file mode 100644 index 00000000..93c632b9 --- /dev/null +++ b/R/map_wastd.R @@ -0,0 +1,264 @@ +#' Map Marine Wildlife Incident 0.6 +#' +#' \lifecycle{maturing} +#' +#' @details Creates a Leaflet map with an interactive legend offering to toggle +#' each species separately. The maps auto-zooms to the extent of data given. +#' +#' @template param-wastd-data +#' @param map_animals Whether to map animals (AnimalEncounters), default: TRUE +#' @param map_tracks Whether to map tracks (TurtleNestEncounters), default: TRUE +#' @param map_dist Whether to map nest and general disturbances +#' (Encounters with TurtleNestDisturbanceObservation), default: TRUE +#' @param map_sites Whether to map Sites, default: TRUE +#' @template param-wastd_url +#' @template param-fmt +#' @template param-tz +#' @template param-cluster +#' @return A leaflet map +#' @export +#' @family wastd +#' @examples +#' data(wastd_data) +#' map_wastd(wastd_data) +map_wastd <- function(x, + map_animals = TRUE, + map_tracks = TRUE, + map_dist = TRUE, + map_sites = TRUE, + wastd_url = wastdr::get_wastd_url(), + fmt = "%Y-%m-%d %H:%M", + tz = "Australia/Perth", + cluster = FALSE) { + # Data gatechecks ---------------------------------------------------------# + if (class(x) != "wastd_data") { + wastdr_msg_abort( + glue::glue( + "The first argument needs to be an object of class \"wastd_data\", ", + "e.g. the output of wastdr::download_wastd_turtledata." + ) + ) + } + + animals <- x$animals %>% filter_realspecies() + animals_alive <- x$animals %>% filter_realspecies() %>% filter_alive() + animals_dead <- x$animals %>% filter_realspecies() %>% filter_dead() + tracks <- x$tracks %>% filter_realspecies() + + if (is.null(animals) || nrow(animals) == 0) { + if (map_animals == TRUE) + wastdr_msg_info("AnimalEncounters requested but none found") + map_animals = FALSE + } + + if (is.null(tracks) || nrow(tracks) == 0) { + if (map_tracks == TRUE) + wastdr_msg_info("TurtleNestEncounters requested but none found") + map_tracks = FALSE + } + + if (is.null(x$nest_dist) || nrow(x$nest_dist) == 0) { + if (map_dist == TRUE) + wastdr_msg_info("TurtleNestDisturbances requested but none found") + map_dist = FALSE + } + + if (is.null(x$sites) || nrow(x$sites) == 0) { + if (map_sites == TRUE) + wastdr_msg_info("Sites requested but none found") + map_sites = FALSE + } + + # Map options -------------------------------------------------------------# + co <- + if (cluster == TRUE) + leaflet::markerClusterOptions() + else + NULL + overlay_names <- c() + url <- sub("/$", "", wastd_url) + + animal_popup_template <- ' +

{humanize(health)} {humanize(maturity)} +{humanize(sex)} {humanize(species)}

+ + +{area_name} - {site_name}
+ + +{format(datetime, fmt)} AWST
+ +{observer_name}
+ +{reporter_name}
+ + +Cause of death: {humanize(cause_of_death)}
+ +Activity: {humanize(activity)}
+ +

Edit on WAStD

' + + animal_label_template <- " +{lubridate::with_tz(datetime, tz)} +{humanize(health)} +{humanize(maturity)} +{humanize(sex)} +{humanize(species)}" + + tracks_label_template <- ' +{lubridate::with_tz(datetime, tz)} {humanize(nest_age)} +{humanize(species)} {humanize(nest_type)} {name}' + + tracks_popup_template <- ' +

{humanize(nest_age)} {humanize(species)} +{humanize(nest_type)} {name}

+ + +{area_name} - {site_name}
+ + +{lubridate::with_tz(datetime, tz)}
+ +{observer_name}
+ +{reporter_name}
+ +

Survey {survey_id} at {site_name} +{format(httpdate_as_gmt08(survey_start_time), fmt)}- +{format(httpdate_as_gmt08(survey_end_time), fmt)} AWST

+ +

Edit on WAStD

' + + dist_label_template <- ' +{lubridate::with_tz(datetime, tz)} {humanize(disturbance_cause)}' + + dist_popup_template <- ' +

Signs of {humanize(disturbance_cause)} +({humanize(encounter_encounter_type)})

+ + +{encounter_area_name} - {encounter_site_name}
+ + +{lubridate::with_tz(datetime, tz)} AWST
+ + +{encounter_observer_name}
+ +{encounter_reporter_name}
+ + +{encounter_comments}
+ +

Survey {encounter_survey_id} at {encounter_site_name}
+{encounter_survey_start_time}-{encounter_survey_end_time}

+ +Edit survey in WAStD + +

+Edit record in WAStD

' + + # Base map ----------------------------------------------------------------# + l <- leaflet::leaflet(width = 800, height = 600) %>% + leaflet::addProviderTiles("Esri.WorldImagery", group = "Basemap") %>% + leaflet::addProviderTiles( + "OpenStreetMap.Mapnik", + group = "Basemap", + options = leaflet::providerTileOptions(opacity = 0.35) + ) %>% + leaflet.extras::addFullscreenControl(pseudoFullscreen = TRUE) %>% + leaflet::clearBounds() + + # AnimalEncounters --------------------------------------------------------# + if (map_animals == TRUE) { + overlay_names <- c(overlay_names, + "Live sightings (tags, rescue)", + "Mortalities (strandings)") + + l <- l %>% + leaflet::addAwesomeMarkers( + data = animals_alive, + lng = ~ longitude, + lat = ~ latitude, + icon = leaflet::makeAwesomeIcon(markerColor = "green", + iconColor = "white"), + label = ~ glue::glue(animal_label_template), + popup = ~ glue::glue(animal_popup_template), + group = "Live sightings (tags, rescue)", + clusterOptions = co + ) %>% + leaflet::addAwesomeMarkers( + data = animals_dead, + lng = ~ longitude, + lat = ~ latitude, + icon = leaflet::makeAwesomeIcon(markerColor = "red", + iconColor = "white"), + label = ~ glue::glue(animal_label_template), + popup = ~ glue::glue(animal_popup_template), + group = "Mortalities (strandings)", + clusterOptions = co + ) + } + + # Tracks ------------------------------------------------------------------# + if (map_tracks == TRUE) { + overlay_names <- c(overlay_names, "Tracks and Nests") + l <- l %>% + leaflet::addAwesomeMarkers( + data = tracks, + lng = ~ longitude, + lat = ~ latitude, + icon = leaflet::makeAwesomeIcon(markerColor = "blue", + iconColor = "white"), + label = ~ glue::glue(tracks_label_template), + popup = ~ glue::glue(tracks_popup_template), + group = "Tracks and Nests", + clusterOptions = co + ) + } + + # Dist --------------------------------------------------------------------# + if (map_dist == TRUE) { + overlay_names <- c(overlay_names, "Disturbances") + l <- l %>% + leaflet::addAwesomeMarkers( + data = x$nest_dist, + lng = ~ encounter_longitude, + lat = ~ encounter_latitude, + icon = leaflet::makeAwesomeIcon(markerColor = "orange", + iconColor = "white"), + label = ~ glue::glue(dist_label_template), + popup = ~ glue::glue(dist_popup_template), + group = "Disturbances", + clusterOptions = co + ) + } + + # Sites -------------------------------------------------------------------# + l %>% { + if (map_sites == TRUE) { + overlay_names <- c(overlay_names, "Sites") + leaflet::addPolygons( + ., + data = x$sites, + group = "Sites", + weight = 1, + fillOpacity = 0.5, + fillColor = "blue", + label = ~ site_name + ) + } else {.} + } %>% + leaflet::addLayersControl( + baseGroups = c("Basemap"), + overlayGroups = overlay_names, + options = leaflet::layersControlOptions(collapsed = FALSE) + ) +} + +# usethis::use_test("map_wastd") diff --git a/R/summarise_mwi.R b/R/summarise_mwi.R index f450e954..b2481c2b 100644 --- a/R/summarise_mwi.R +++ b/R/summarise_mwi.R @@ -20,6 +20,11 @@ #' filter_alive() %>% #' head() filter_alive <- function(data) { + if (is.null(data) || nrow(data) == 0) { + wastdr_msg_warn("[filter_alive] missing data") + return(data) + } + flt_col <- dplyr::case_when( "status_health" %in% names(data) ~ "status_health", TRUE ~ "health" @@ -58,6 +63,11 @@ filter_alive <- function(data) { #' filter_dead() %>% #' head() filter_dead <- function(data) { + if (is.null(data) || nrow(data) == 0) { + wastdr_msg_warn("[filter_dead] missing data") + return(data) + } + flt_col <- dplyr::case_when( "status_health" %in% names(data) ~ "status_health", TRUE ~ "health" @@ -75,6 +85,7 @@ filter_dead <- function(data) { ) data %>% dplyr::filter(!!rlang::sym(flt_col) %in% flt_val) + } # usethis::use_test("summarise_mwi") diff --git a/man/add_nest_labels.Rd b/man/add_nest_labels.Rd index 28cc4fd0..2fee0a70 100644 --- a/man/add_nest_labels.Rd +++ b/man/add_nest_labels.Rd @@ -42,6 +42,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/disturbance_by_season.Rd b/man/disturbance_by_season.Rd index a3488e81..32c8b602 100644 --- a/man/disturbance_by_season.Rd +++ b/man/disturbance_by_season.Rd @@ -45,6 +45,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/filter_alive.Rd b/man/filter_alive.Rd index 8c4390d6..669bc6e4 100644 --- a/man/filter_alive.Rd +++ b/man/filter_alive.Rd @@ -45,6 +45,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/filter_dead.Rd b/man/filter_dead.Rd index 28f23903..1ebc288a 100644 --- a/man/filter_dead.Rd +++ b/man/filter_dead.Rd @@ -45,6 +45,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/filter_disturbance.Rd b/man/filter_disturbance.Rd index f314de89..e78c2ac9 100644 --- a/man/filter_disturbance.Rd +++ b/man/filter_disturbance.Rd @@ -52,6 +52,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/filter_predation.Rd b/man/filter_predation.Rd index 37848f97..e16c71b5 100644 --- a/man/filter_predation.Rd +++ b/man/filter_predation.Rd @@ -52,6 +52,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/ggplot_track_success_by_date.Rd b/man/ggplot_track_success_by_date.Rd index 90e0d6a5..db0a2091 100644 --- a/man/ggplot_track_success_by_date.Rd +++ b/man/ggplot_track_success_by_date.Rd @@ -51,6 +51,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/ggplot_track_successrate_by_date.Rd b/man/ggplot_track_successrate_by_date.Rd index 7c1cb174..f966dbfa 100644 --- a/man/ggplot_track_successrate_by_date.Rd +++ b/man/ggplot_track_successrate_by_date.Rd @@ -52,6 +52,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/hatching_emergence_success.Rd b/man/hatching_emergence_success.Rd index f986c9aa..5af51f11 100644 --- a/man/hatching_emergence_success.Rd +++ b/man/hatching_emergence_success.Rd @@ -32,6 +32,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/hatching_emergence_success_area.Rd b/man/hatching_emergence_success_area.Rd index fa3a69ac..11957bd8 100644 --- a/man/hatching_emergence_success_area.Rd +++ b/man/hatching_emergence_success_area.Rd @@ -32,6 +32,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/hatching_emergence_success_site.Rd b/man/hatching_emergence_success_site.Rd index a98a72de..82e03189 100644 --- a/man/hatching_emergence_success_site.Rd +++ b/man/hatching_emergence_success_site.Rd @@ -32,6 +32,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/map_dist.Rd b/man/map_dist.Rd index e8981d12..fa336d0e 100644 --- a/man/map_dist.Rd +++ b/man/map_dist.Rd @@ -59,6 +59,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/map_mwi.Rd b/man/map_mwi.Rd index ccc4c12d..db927c21 100644 --- a/man/map_mwi.Rd +++ b/man/map_mwi.Rd @@ -61,6 +61,7 @@ Other wastd: \code{\link{map_dist}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/map_nests.Rd b/man/map_nests.Rd index 7e6f6506..cda6bea5 100644 --- a/man/map_nests.Rd +++ b/man/map_nests.Rd @@ -56,6 +56,7 @@ Other wastd: \code{\link{map_dist}()}, \code{\link{map_mwi}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/map_tracks.Rd b/man/map_tracks.Rd index eb875ee9..520e35b8 100644 --- a/man/map_tracks.Rd +++ b/man/map_tracks.Rd @@ -65,6 +65,7 @@ Other wastd: \code{\link{map_dist}()}, \code{\link{map_mwi}()}, \code{\link{map_nests}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/map_wastd.Rd b/man/map_wastd.Rd new file mode 100644 index 00000000..51669fd9 --- /dev/null +++ b/man/map_wastd.Rd @@ -0,0 +1,101 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/map_wastd.R +\name{map_wastd} +\alias{map_wastd} +\title{Map Marine Wildlife Incident 0.6} +\usage{ +map_wastd( + x, + map_animals = TRUE, + map_tracks = TRUE, + map_dist = TRUE, + map_sites = TRUE, + wastd_url = wastdr::get_wastd_url(), + fmt = "\%Y-\%m-\%d \%H:\%M", + tz = "Australia/Perth", + cluster = FALSE +) +} +\arguments{ +\item{x}{An object of S3 class \code{wastd_data}, e.g. the output of +\code{wastdr::download_wastd_turtledata()}, optionally filtered to a locality +by \code{wastdr::filter_wastd_turtledata(area_name="Thevenard Island")}.} + +\item{map_animals}{Whether to map animals (AnimalEncounters), default: TRUE} + +\item{map_tracks}{Whether to map tracks (TurtleNestEncounters), default: TRUE} + +\item{map_dist}{Whether to map nest and general disturbances +(Encounters with TurtleNestDisturbanceObservation), default: TRUE} + +\item{map_sites}{Whether to map Sites, default: TRUE} + +\item{wastd_url}{The base URL for WAStD, default: \code{get_wastd_url()}} + +\item{fmt}{The desired date format, default: "d/m/Y H:M"} + +\item{tz}{The lubridate timezone, default: "Australia/Perth} + +\item{cluster}{If TRUE, cluster map markers. Default: FALSE. +Note: In some places, the aerial background layer does not provide imagery +at sufficient zoom levels, and therefore restricts the map zoom at levels +where the cluster markers don't expand. Switch to "Place names" to let +cluster markers expand.} +} +\value{ +A leaflet map +} +\description{ +\lifecycle{maturing} +} +\details{ +Creates a Leaflet map with an interactive legend offering to toggle +each species separately. The maps auto-zooms to the extent of data given. +} +\examples{ +data(wastd_data) +map_wastd(wastd_data) +} +\seealso{ +Other wastd: +\code{\link{add_nest_labels}()}, +\code{\link{disturbance_by_season}()}, +\code{\link{filter_alive}()}, +\code{\link{filter_dead}()}, +\code{\link{filter_disturbance}()}, +\code{\link{filter_predation}()}, +\code{\link{ggplot_track_success_by_date}()}, +\code{\link{ggplot_track_successrate_by_date}()}, +\code{\link{hatching_emergence_success_area}()}, +\code{\link{hatching_emergence_success_site}()}, +\code{\link{hatching_emergence_success}()}, +\code{\link{map_dist}()}, +\code{\link{map_mwi}()}, +\code{\link{map_nests}()}, +\code{\link{map_tracks}()}, +\code{\link{nesting_type_by_area_season_age_species}()}, +\code{\link{nesting_type_by_area_season_species}()}, +\code{\link{nesting_type_by_season_age_species}()}, +\code{\link{nesting_type_by_season_calendarday_age_species}()}, +\code{\link{nesting_type_by_season_calendarday_species}()}, +\code{\link{nesting_type_by_season_day_species}()}, +\code{\link{nesting_type_by_season_species}()}, +\code{\link{nesting_type_by_season_week_age_species}()}, +\code{\link{nesting_type_by_season_week_site_species}()}, +\code{\link{nesting_type_by_season_week_species}()}, +\code{\link{nesting_type_by_site_season_age_species}()}, +\code{\link{nesting_type_by_site_season_species}()}, +\code{\link{parse_animal_encounters}()}, +\code{\link{parse_area_sf}()}, +\code{\link{parse_area}()}, +\code{\link{parse_encounterobservations}()}, +\code{\link{parse_surveys}()}, +\code{\link{parse_turtle_nest_encounters}()}, +\code{\link{print.wastd_api_response}()}, +\code{\link{summarise_hatching_and_emergence_success}()}, +\code{\link{summarise_wastd_data_per_day_site}()}, +\code{\link{track_success_by_species}()}, +\code{\link{track_success}()}, +\code{\link{tracks_ts}()} +} +\concept{wastd} diff --git a/man/nesting_type_by_area_season_age_species.Rd b/man/nesting_type_by_area_season_age_species.Rd index 27c289ae..329a24f3 100644 --- a/man/nesting_type_by_area_season_age_species.Rd +++ b/man/nesting_type_by_area_season_age_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, \code{\link{nesting_type_by_season_calendarday_age_species}()}, diff --git a/man/nesting_type_by_area_season_species.Rd b/man/nesting_type_by_area_season_species.Rd index d4369daa..9a11a5f8 100644 --- a/man/nesting_type_by_area_season_species.Rd +++ b/man/nesting_type_by_area_season_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_season_age_species}()}, \code{\link{nesting_type_by_season_calendarday_age_species}()}, diff --git a/man/nesting_type_by_season_age_species.Rd b/man/nesting_type_by_season_age_species.Rd index 84183f5b..c7c31f11 100644 --- a/man/nesting_type_by_season_age_species.Rd +++ b/man/nesting_type_by_season_age_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_calendarday_age_species}()}, diff --git a/man/nesting_type_by_season_calendarday_age_species.Rd b/man/nesting_type_by_season_calendarday_age_species.Rd index f8cdae84..874074ba 100644 --- a/man/nesting_type_by_season_calendarday_age_species.Rd +++ b/man/nesting_type_by_season_calendarday_age_species.Rd @@ -34,6 +34,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_season_calendarday_species.Rd b/man/nesting_type_by_season_calendarday_species.Rd index 0b1b4ba2..d4c5ae0c 100644 --- a/man/nesting_type_by_season_calendarday_species.Rd +++ b/man/nesting_type_by_season_calendarday_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_season_day_species.Rd b/man/nesting_type_by_season_day_species.Rd index fdb886e9..ecb48c69 100644 --- a/man/nesting_type_by_season_day_species.Rd +++ b/man/nesting_type_by_season_day_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_season_species.Rd b/man/nesting_type_by_season_species.Rd index 2fc09ec4..69879ec7 100644 --- a/man/nesting_type_by_season_species.Rd +++ b/man/nesting_type_by_season_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_season_week_age_species.Rd b/man/nesting_type_by_season_week_age_species.Rd index 9047dced..1fc0da16 100644 --- a/man/nesting_type_by_season_week_age_species.Rd +++ b/man/nesting_type_by_season_week_age_species.Rd @@ -34,6 +34,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_season_week_site_species.Rd b/man/nesting_type_by_season_week_site_species.Rd index 60402cc5..d5f445c2 100644 --- a/man/nesting_type_by_season_week_site_species.Rd +++ b/man/nesting_type_by_season_week_site_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_season_week_species.Rd b/man/nesting_type_by_season_week_species.Rd index e19b3017..68a6bc7f 100644 --- a/man/nesting_type_by_season_week_species.Rd +++ b/man/nesting_type_by_season_week_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_site_season_age_species.Rd b/man/nesting_type_by_site_season_age_species.Rd index 3880baef..4486bced 100644 --- a/man/nesting_type_by_site_season_age_species.Rd +++ b/man/nesting_type_by_site_season_age_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/nesting_type_by_site_season_species.Rd b/man/nesting_type_by_site_season_species.Rd index 0c608905..06e726ff 100644 --- a/man/nesting_type_by_site_season_species.Rd +++ b/man/nesting_type_by_site_season_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/parse_animal_encounters.Rd b/man/parse_animal_encounters.Rd index 4c8c978c..cdc5ef63 100644 --- a/man/parse_animal_encounters.Rd +++ b/man/parse_animal_encounters.Rd @@ -76,6 +76,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/parse_area.Rd b/man/parse_area.Rd index 8cedd373..668ac26a 100644 --- a/man/parse_area.Rd +++ b/man/parse_area.Rd @@ -43,6 +43,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/parse_area_sf.Rd b/man/parse_area_sf.Rd index fadfc39a..7c2a5bc8 100644 --- a/man/parse_area_sf.Rd +++ b/man/parse_area_sf.Rd @@ -43,6 +43,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/parse_encounterobservations.Rd b/man/parse_encounterobservations.Rd index 1c2b1365..7bd0842f 100644 --- a/man/parse_encounterobservations.Rd +++ b/man/parse_encounterobservations.Rd @@ -56,6 +56,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/parse_surveys.Rd b/man/parse_surveys.Rd index 3a2a8eff..9d6c6e80 100644 --- a/man/parse_surveys.Rd +++ b/man/parse_surveys.Rd @@ -75,6 +75,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/parse_turtle_nest_encounters.Rd b/man/parse_turtle_nest_encounters.Rd index b84baabd..12e810f6 100644 --- a/man/parse_turtle_nest_encounters.Rd +++ b/man/parse_turtle_nest_encounters.Rd @@ -77,6 +77,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/print.wastd_api_response.Rd b/man/print.wastd_api_response.Rd index 16c1a5f4..59c1aaef 100644 --- a/man/print.wastd_api_response.Rd +++ b/man/print.wastd_api_response.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/summarise_hatching_and_emergence_success.Rd b/man/summarise_hatching_and_emergence_success.Rd index 9e691a2b..598320d5 100644 --- a/man/summarise_hatching_and_emergence_success.Rd +++ b/man/summarise_hatching_and_emergence_success.Rd @@ -48,6 +48,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/summarise_wastd_data_per_day_site.Rd b/man/summarise_wastd_data_per_day_site.Rd index 1b85216c..f1afe798 100644 --- a/man/summarise_wastd_data_per_day_site.Rd +++ b/man/summarise_wastd_data_per_day_site.Rd @@ -110,6 +110,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/track_success.Rd b/man/track_success.Rd index 741ee759..265e8529 100644 --- a/man/track_success.Rd +++ b/man/track_success.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/track_success_by_species.Rd b/man/track_success_by_species.Rd index cb8e9b6f..3728dd82 100644 --- a/man/track_success_by_species.Rd +++ b/man/track_success_by_species.Rd @@ -33,6 +33,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/man/tracks_ts.Rd b/man/tracks_ts.Rd index 668fd1aa..650e6e17 100644 --- a/man/tracks_ts.Rd +++ b/man/tracks_ts.Rd @@ -50,6 +50,7 @@ Other wastd: \code{\link{map_mwi}()}, \code{\link{map_nests}()}, \code{\link{map_tracks}()}, +\code{\link{map_wastd}()}, \code{\link{nesting_type_by_area_season_age_species}()}, \code{\link{nesting_type_by_area_season_species}()}, \code{\link{nesting_type_by_season_age_species}()}, diff --git a/tests/testthat/test-map_wastd.R b/tests/testthat/test-map_wastd.R new file mode 100644 index 00000000..1dbaf55d --- /dev/null +++ b/tests/testthat/test-map_wastd.R @@ -0,0 +1,9 @@ +test_that("map_wastd gatechecks for missing data", { + expect_error(map_wastd(NULL)) +}) + +test_that("map_wastd returns a leaflet htmlwidget", { + data("wastd_data") + themap <- map_wastd(wastd_data) + testthat::expect_equal(class(themap), c("leaflet", "htmlwidget")) +})