Map and save a ctdf object
map.RdVisualize 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
ctdfobject produced bycluster_track().- fix_dateline
Logical. If
TRUE, geometries are adjusted withsf::st_wrap_dateline().- x
A
leafletmap object produced bymap().- path
Character. Directory where the HTML map will be saved.
- name
Character. File name stem for the saved map. Defaults to the
map_nameattribute set bymap().- selfcontained
Logical. Passed to
htmlwidgets::saveWidget(). Set it toTRUEonly 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.
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")
} # }