
Plot data interactively
Johannes Krietsch
Source:vignettes/visualization_tutorials/plot_data_interactively.Rmd
plot_data_interactively.Rmd
This article shows different ways on how to plot WATLAS data
interactively using mapview
. This is useful when manually
checking specific data. Check for more details the mapview
website. Note that one can change the base map by clicking in the
layer symbol, to for example a satellite image. Each chunk of code only
requires this chunk with loading the data to be run before and is
otherwise independent.
Load packages
# packages
library(tools4watlas)
library(mapview)
Interactive plot for one individual
Subset the individual of choice and transform it into a
sf
with the additional columns of your choice (can be seen
when clicking on the point). Colour the track by selecting the desired
parameter as zcol
.
# load example data
data <- data_example
# subset data
data_subset <- data[tag == "3063"]
# make data spatial
d_sf <- atl_as_sf(
data_subset,
additional_cols = c("species", "datetime", "speed_in", "nbs", "waterlevel")
)
# add track
d_sf_lines <- atl_as_sf(
data_subset,
additional_cols = c("species", "datetime", "speed_in", "nbs", "waterlevel"),
option = "lines"
)
# plot interactive map
mapview(d_sf_lines, zcol = "speed_in", legend = FALSE) +
mapview(d_sf, zcol = "speed_in")
Interactive plot for multiple individuals
# load example data
data <- data_example
# make data spatial
d_sf <- atl_as_sf(data, additional_cols = c("datetime", "species"))
# add track
d_sf_lines <- atl_as_sf(
data,
additional_cols = c("species"),
option = "lines"
)
# plot interactive map
mapview(d_sf_lines, zcol = "tag", legend = FALSE) +
mapview(d_sf, zcol = "tag")
Interactive plot for multiple species
# load example data
data <- data_example
# make data spatial
d_sf <- atl_as_sf(data, additional_cols = c("datetime", "species"))
# add track
d_sf_lines <- atl_as_sf(
data,
additional_cols = c("species"),
option = "lines"
)
# plot interactive map
mapview(d_sf_lines, zcol = "species", legend = FALSE) +
mapview(d_sf, zcol = "species")