Description Usage Arguments Examples
View source: R/mermaid_map_sites_static.R
Create a static map of sample events sites, zoomed in to the site locations. If plot_var
is supplied, then the site points are based on plot_var
- if it is a numeric variable, the sizes of the points vary with the sizes of the variable. If it is a character, factor, or logical variable, then the colours of the points vary with the different values of the variable. The map returned is a ggplot2
plot, and so ggplot2
layers can be built upon it for further customization - please see the examples section.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | mermaid_map_sites_static(
.data,
plot_var = NULL,
use_fiji_crs = FALSE,
bb_ext = 1.1,
jitter = 0.01,
size = 2,
colour = "red",
alpha = 0.5,
label_sites = FALSE,
label_axes = TRUE,
scale = FALSE,
scale_position = c("bottomright", "bottomleft", "topright", "topleft"),
arrow = FALSE,
arrow_position = c("bottomright", "bottomleft", "topright", "topleft"),
legend = TRUE,
legend_position = c("right", "left", "top", "bottom"),
latitude_bounds = NULL,
longitude_bounds = NULL
)
|
.data |
Data frame with latitude and longitude of sample events sites. |
plot_var |
Variable to plot by (optional). |
use_fiji_crs |
Whether to use a coordinate reference system appropriate for mapping Fiji data. Defaults to FALSE. |
bb_ext |
Extension factor of the map's bounding box. Values smaller than 1 reduce the bounding box, and values larger than 1 enlarge the bounding box. The default is 1.1. |
jitter |
Amount of jittering applied to points. Defaults to 0.01. Set to 0 to remove jittering. |
size |
Size of points (when |
colour |
Colour of points (when |
alpha |
Opacity of points. Defaults to 0.5. |
label_sites |
Whether the sites should be labeled. Defaults to FALSE. Sites are labeled by the variable |
label_axes |
Whether the axes should be labeled. Defaults to TRUE. |
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". |
arrow |
Whether there should be a North arrow. Defaults to FALSE. |
arrow_position |
The position of the arrow, if there is one. One of "bottomright", "bottomleft", "topright", "topleft". Defaults to "bottomright". |
legend |
Whether there should be a plot legend (if |
legend_position |
Position of the plot legend. One of "right", "left", "top", "bottom". Defaults to "right". |
latitude_bounds |
Latitude bounds for the map. If both |
longitude_bounds |
Longitude bounds for the map. If both |
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 35 36 37 38 39 40 41 42 | library(mermaidr)
sample_events <- mermaid_search_projects(name = "XPDC Kei Kecil 2018") %>%
mermaid_get_project_data("fishbelt", "sampleevents", limit = 25)
# Default map
mermaid_map_sites_static(sample_events)
# Map sites by value of biomass_kgha_avg
mermaid_map_sites_static(sample_events, biomass_kgha_avg)
# Map sites by value of reef_exposure
mermaid_map_sites_static(sample_events, reef_exposure)
# Remove legend
mermaid_map_sites_static(sample_events, reef_exposure, legend = FALSE)
# Change legend position
mermaid_map_sites_static(sample_events, reef_exposure, legend_position = "bottom")
# Add labels for sites
mermaid_map_sites_static(sample_events, label_sites = TRUE)
# Add arrow and scale bar
mermaid_map_sites_static(sample_events, scale = TRUE, arrow = TRUE)
# Change position of arrow
mermaid_map_sites_static(sample_events, scale = TRUE, arrow = TRUE, arrow_position = "topleft")
# Remove axes labels
mermaid_map_sites_static(sample_events, label_axes = FALSE)
# Map sites with user-specified latitude and longitude bounds
mermaid_map_sites_static(sample_events,
latitude_bounds = c(-6, -5),
longitude_bounds = c(132, 133)
)
# Since the map returned is a ggplot2 object, further customization can
# be done with ggplot2 code. For example, adding a title to the map
library(ggplot2)
mermaid_map_sites_static(sample_events, biomass_kgha_avg) +
labs(title = "Sites by mean total biomass")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.