mermaid_map_sites_interactive: Create an interactive map of MERMAID sample events sites

Description Usage Arguments Examples

View source: R/mermaid_map_sites_interactive.R

Description

Create an interactive map of sites, zoomed in to the sample events sites. If plot_var is supplied, then the colour of the site points are based on plot_var. The map returned is a leaflet plot, and so leaflet layers can be built upon it for further customization - please see the examples section.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
mermaid_map_sites_interactive(
  .data,
  plot_var = NULL,
  basemap = "Esri.WorldImagery",
  jitter = 0.01,
  size = 2,
  colour = "red",
  alpha = 0.5,
  scale = FALSE,
  scale_position = c("bottomright", "bottomleft", "topright", "topleft"),
  legend = TRUE,
  legend_position = c("bottomright", "bottomleft", "topright", "topleft")
)

Arguments

.data

Data frame with latitude and longitude of sites.

plot_var

Variable to plot by (optional).

basemap

Basemap layer. See http://leaflet-extras.github.io/leaflet-providers/preview/ for options. Defaults to "Esri.WorldImagery".

jitter

Amount of jittering applied to points. Defaults to 0.01. Set to 0 to remove jittering.

size

Size of points (when plot_var is not a numeric variable). Defaults to 2.

colour

Colour of points (when plot_var is not a character, factor, or logical variable). Defaults to red.

alpha

Opacity of points. Defaults to 0.5.

scale

Whether there should be a scale bar. Defaults to FALSE.

scale_position

The position of the scale bar, if there is one. One of "bottomright", "bottomleft", "topright", "topleft". Defaults to "bottomright".

legend

Whether there should be a plot legend (if plot_var is specified). Defaults to TRUE.

legend_position

Position of the plot legend. One of "bottomright", "bottomleft", "topright", "topleft". Defaults to "bottomright".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(mermaidr)
sample_events <- mermaid_search_projects(name = "XPDC Kei Kecil 2018") %>%
  mermaid_get_project_data("fishbelt", "sampleevents")

# Default map
mermaid_map_sites_interactive(sample_events)

# Map sites by value of biomass_kgha_avg
mermaid_map_sites_interactive(sample_events, biomass_kgha_avg)

# Map sites by value of reef_exposure
mermaid_map_sites_interactive(sample_events, reef_exposure)

# Remove legend
mermaid_map_sites_interactive(sample_events, reef_exposure, legend = FALSE)

# Change legend position
mermaid_map_sites_interactive(sample_events, reef_exposure, legend_position = "topright")

# Add scale bar
mermaid_map_sites_interactive(sample_events, scale = TRUE)

# Change position of scale bar
mermaid_map_sites_interactive(sample_events, scale = TRUE, scale_position = "topright")

# Since the map returned is a leaflet object, further customization can
# be done with leaflet code. For example, adding a mini-map for further navigation:
mermaid_map_sites_interactive(sample_events) %>%
  leaflet::addMiniMap()

# You can also save a static image of the map using the mapview package:
library(mapview)
m <- mermaid_map_sites_interactive(sample_events, reef_exposure, legend_position = "topright")
mapshot(m, file = "sites_by_management_rule.png")

data-mermaid/mermaidreporting documentation built on May 23, 2020, 7 a.m.