Skip to contents

Visualize clustered track data on an interactive leaflet map and optionally save the resulting widget with save_map().

Usage

map(ctdf, fix_dateline = FALSE)

save_map(
  x,
  path,
  name = attr(x, "map_name", exact = TRUE),
  selfcontained = FALSE,
  libdir = "assets"
)

Arguments

ctdf

A ctdf object produced by cluster_track().

fix_dateline

Logical. If TRUE, geometries are adjusted with sf::st_wrap_dateline().

x

A leaflet map object produced by map().

path

Character. Directory where the HTML map will be saved.

name

Character. File name stem for the saved map. Defaults to the map_name attribute set by map().

selfcontained

Logical. Passed to htmlwidgets::saveWidget(). Set it to TRUE only when you want to save a single map.

libdir

Character. Directory for widget assets when selfcontained = FALSE.

Value

map() returns a leaflet map object with a map_name attribute.

save_map() invisibly returns the written HTML file path.

Details

map() builds a leaflet map from a ctdf object. The returned map stores the input object name in its map_name attribute, which is used by save_map() as the output HTML filename.

Functions

  • save_map(): Save a leaflet map produced by map() as an HTML widget.

Examples

data(mini_ruff)

ctdf = as_ctdf(mini_ruff)
map(ctdf)
#> Warning: this ctdf does not have any clusters!
ctdf = cluster_track(ctdf) #> → Find putative cluster regions. #> ! Repairing[1]... #> → Local clustering. #> ! Repairing[2]... #> ! Compute lof scores... mm = map(ctdf) mm
if (FALSE) { # \dontrun{ mm |> leaflet::addMarkers(lng = 11, lat = 47) |> save_map(path = "~/Desktop/temp") } # }