Skip to contents

This function visualizes deployments features such as number of detected species, number of observations and RAI (Relative Abundance Index) on a dynamic map. The circle size and color are proportional to the mapped feature.

Usage

map_summary(
  df,
  feature,
  effort_unit = NULL,
  cluster = TRUE,
  hover_columns = c(dplyr::group_vars(df), feature),
  palette = "inferno",
  zero_values_show = TRUE,
  zero_values_icon_url = "https://img.icons8.com/ios-glyphs/30/000000/multiply.png",
  zero_values_icon_size = 10,
  na_values_show = TRUE,
  na_values_icon_url = "https://img.icons8.com/ios-glyphs/30/FA5252/multiply.png",
  na_values_icon_size = 10,
  relative_scale = TRUE,
  max_scale = NULL,
  radius_range = c(10, 50)
)

Arguments

df

Grouped data frame generated by summarize_deployments() or summarize_observations() or eventually a subset of it. If columns latitude and longitude are not present in df, no map can be generated and an error is returned.

feature

Feature to visualize. One of the columns generated by summarize_deployments() or summarize_observations() not used for grouping. Possible values present in output of summarize_observations() are:

  • n_scientificName: Number of detected species.

  • n_events: Number of events observed.

  • n_observations: Number of observations.

  • sum_count: Number of individuals observed.

  • rai_observations: RAI calculated using the number of observations (n_observations).

  • rai_count: RAI calculated using the number of observed individuals (sum_count).

Possible values present in output of summarize_deployments() are:

  • effort_duration: Deployment effort duration.

effort_unit

Time unit to use while visualizing deployment effort duration. Ignored if feature is not "effort_duration". One of:

  • second

  • minute

  • hour

  • day

  • month

  • year

If NULL (default), the effort is returned in hours.

cluster

Logical value indicating whether using the cluster option while visualizing maps. Default: TRUE.

hover_columns

Character vector of the columns of df to show on mouse hover. Use NULL to disable hovering. Default: all columns in df used for grouping and the feature to visualize.

palette

The palette name or the color function that values will be mapped to. Default: "inferno". Typically one of the following:

  • A character vector of RGB or named colors. Examples: c("#000000", "#0000FF", "#FFFFFF")),topo.colors(10)).

  • The full name of a RColorBrewer palette, e.g. "BuPu" or "Greens", or viridis palette: "viridis", "magma", "inferno" or "plasma".

For more options, see parameter palette of leaflet::colorNumeric().

zero_values_show

Logical indicating whether to show deployments with zero values. Default: TRUE. See details.

zero_values_icon_url

Character with URL to icon for showing deployments with zero values. Use NULL if zero_values_show is FALSE. Default: a cross (multiply symbol) "https://img.icons8.com/ios-glyphs/30/000000/multiply.png". See details.

zero_values_icon_size

A number to set the size of the icon to show groups (e.g. deployments) with zero values. Use NULL if zero_values_show is FALSE. Default: a cross (multiply symbol) "https://img.icons8.com/ios-glyphs/30/000000/multiply.png". See details.

na_values_show

Logical indicating whether to show groups (e.g. deployments) with no observations when feature is "n_scientificName". Default: TRUE. See details.

na_values_icon_url

Character with URL to icon for showing groups (e.g. deployments) with no observations. Used only if feature is "n_scientificName", ignored otherwise. Use NULL if na_values_show is FALSE. Default: a red cross (multiply symbol) "https://img.icons8.com/ios-glyphs/30/FA5252/multiply.png".

na_values_icon_size

A number to set the size of the icon for showing groups (e.g. deployments) with no observations. Used only if feature is "n_scientificName", ignored otherwise. Use NULL if na_values_show is FALSE. Default: 10.

relative_scale

Logical indicating whether to use a relative color and radius scale (TRUE) or an absolute scale (FALSE). If absolute scale is used, specify a valid max_scale.

max_scale

Number indicating the max value used to map color and radius.

radius_range

Vector of length 2 containing the lower and upper limit of the circle radius. The lower value is used for deployments with zero feature value, e.g. no observations, no identified species, zero RAI or zero effort. The upper value is used for the deployment(s) with the highest feature value (relative_scale = TRUE) or max_scale (relative_scale = FALSE). Default: c(10, 50).

Value

Leaflet map.

Details

Deployments with zero values are shown only if they are present in the summary, df. If you want to show deployments with zero values not present in the summary, be sure to have used extend = TRUE in summarize_observations(). See the examples.

Notice also that the argument species is not present anymore. If you want to visualize a feature only for a specific group of species, please filter the Camera Trap Data Package using filter_observations() before using this function. See the examples.

Examples

x <- example_dataset()
# Filter a data package to get only the data of Anas platyrhynchos
x_anas_p <- x %>%
  filter_observations(scientificName == "Anas platyrhynchos")

# Show number of species
x %>%
  summarize_observations(
    group_by = c("deploymentID", "latitude", "longitude")
  ) %>%
  map_summary("n_scientificName")
# Show number of species: show deployments with no # observations (NA icon and size as defaults) x_anas_p %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude"), extend = TRUE ) %>% map_summary("n_scientificName")
# Show total number of observations (all species) x %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude") ) %>% map_summary("n_observations")
# Show number of observations of Anas platyrhynchos - show deployments with # no observations (zero icon and size as defaults) x_anas_p %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude"), extend = TRUE ) %>% map_summary("n_observations")
# Show number of observations of Anas platyrhynchos without extending the # summary: deployments with no observations are not shown x_anas_p %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude") ) %>% map_summary("n_observations")
# Same result as above if you extend the summary but use # `zero_values_show` = `FALSE` x_anas_p %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude"), extend = TRUE ) %>% map_summary( "n_observations", zero_values_show = FALSE, zero_values_icon_url = NULL, zero_values_icon_size = NULL )
# You can eventually filter the species after summarizing, # although it could not be the most efficient way for large Camera Trap Data # Packages library(dplyr) x %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude", "scientificName") ) %>% filter(scientificName == "Anas platyrhynchos") %>% map_summary("n_scientificName")
# Show number of individuals x_anas_p %>% summarize_observations() %>% map_summary("sum_count")
# Show RAI x_anas_p %>% summarize_observations() %>% map_summary("rai_observations")
# Show RAI (individual counts) x_anas_p %>% summarize_observations() %>% map_summary("rai_count")
# Show effort (hours) x_anas_p %>% summarize_deployments() %>% map_summary("effort_duration")
# Show effort (days) x %>% summarize_deployments() %>% map_summary("effort_duration", effort_unit = "day")
# Show effort per month x %>% summarize_deployments(group_time_by = "month") %>% map_summary("effort_duration", effort_unit = "day")
# Use viridis palette x_anas_p %>% summarize_observations() %>% map_summary("n_observations", palette = "viridis")
# Use a palette defined by color names x_anas_p %>% summarize_observations() %>% map_summary("n_observations", palette = c("black", "blue", "white"))
# Use a palette defined by hex colors x_anas_p %>% summarize_observations() %>% map_summary("n_observations", palette = c("#000000", "#0000FF", "#FFFFFF"))
# Use same icon but a non default color for zero values deployments, # E.g. red (hex: E74C3C) x_anas_p %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude"), extend = TRUE ) %>% map_summary( "n_observations", zero_values_icon_url = "https://img.icons8.com/ios-glyphs/30/E74C3C/multiply.png" )
# Use another icon via a different URL, e.g. the character Fry from Futurama # in green (2ECC71) x_anas_p %>% summarize_observations(extend = TRUE) %>% map_summary( "n_observations", zero_values_icon_url = "https://img.icons8.com/ios-glyphs/30/2ECC71/futurama-fry.png" )
# Set size of the icon for zero values deployments x %>% filter_observations(scientificName == "Anas platyrhynchos") %>% summarize_observations(extend = TRUE) %>% map_summary("n_observations", zero_values_icon_size = 30)
# Use another icon url/size for visualizing groups with no observations # (NA, only for `n_scientificName` feature) x %>% filter_observations(deploymentID != "00a2c20d") %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude") ) %>% map_summary( feature = "n_scientificName", na_values_icon_url = "https://img.icons8.com/ios-glyphs/30/E74C3C/futurama-fry.png", na_values_icon_size = 60 )
# Disable cluster x %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude") ) %>% map_summary("n_observations", cluster = FALSE)
# Show only number of observations and location name while hovering x %>% summarize_observations( group_by = c("deploymentID", "locationName", "latitude", "longitude") ) %>% map_summary( "n_observations", hover_columns = c("locationName", "n_observations") )
# Use absolute scale for colors and radius x %>% summarize_observations( group_by = c("deploymentID", "latitude", "longitude") ) %>% map_summary( "n_scientificName", relative_scale = FALSE, max_scale = 4 )
# Change max and min size circles x %>% summarize_observations( group_by = c("deploymentID", "locationName", "latitude", "longitude") ) %>% map_summary( "n_observations", radius_range = c(40, 150) )