tmap_save | R Documentation |
Save tmap to a file. This can be either a static plot (e.g. png) or an interactive map (html).
tmap_save(
tm = NULL,
filename = NA,
device = NULL,
width = NA,
height = NA,
units = NA,
dpi = NA,
outer.margins = NA,
asp = NULL,
scale = NA,
insets_tm = NULL,
insets_vp = NULL,
add.titles = TRUE,
in.iframe = FALSE,
selfcontained = !in.iframe,
verbose = NULL,
...
)
tm |
tmap object |
filename |
filename including extension, and optionally the path. The extensions pdf, eps, svg, wmf (Windows only), png, jpg, bmp, tiff, and html are supported. If the extension is missing, the file will be saved as a static plot in |
device |
graphic device to use. Either a device function (e.g., |
height, width |
The width and height of the plot (not applicable for html files). Units are set with the argument |
units |
units for width and height ( |
dpi |
dots per inch. Only applicable for raster graphics. By default it is set to 300, but this can be changed using the option |
outer.margins |
overrides the outer.margins argument of |
asp |
if specified, it overrides the asp argument of |
scale |
overrides the scale argument of |
insets_tm |
tmap object of an inset map, or a list of tmap objects of multiple inset maps. The number of tmap objects should be equal to the number of viewports specified with |
insets_vp |
|
add.titles |
add titles to leaflet object |
in.iframe |
should an interactive map be saved as an iframe? If so, two HTML files will be saved; one small parent HTML file with the iframe container, and one large child HTML file with the actual widget. See |
selfcontained |
when an interactive map is saved, should the resources (e.g. Javascript libraries) be contained in the HTML file? If |
verbose |
Deprecated. It is now controlled by the tmap option |
... |
arguments passed on to device functions or to |
## Not run:
data(NLD_muni, NLD_prov)
m <- tm_shape(NLD_muni) +
tm_fill(col="population", convert2density=TRUE,
style="kmeans",
title=expression("Population (per " * km^2 * ")")) +
tm_borders("black", alpha=.5) +
tm_shape(NLD_prov) +
tm_borders("grey25", lwd=2) +
tm_style("classic") +
tm_format("NLD", inner.margins = c(.02, .15, .06, .15)) +
tm_scale_bar(position = c("left", "bottom")) +
tm_compass(position=c("right", "bottom"))
tmap_save(m, "choropleth.png", height = 7) # height interpreted in inches
tmap_save(m, "choropleth_icon.png", height = 100, scale = .1) # height interpreted in pixels
data(World)
m2 <- tm_shape(World) +
tm_fill("well_being", id="name", title="Well-being") +
tm_format("World")
# save image
tmap_save(m2, "World_map.png", width=1920, height=1080, asp=0)
# cut left inner margin to make sure Antarctica is snapped to frame
tmap_save(m2 + tm_layout(inner.margins = c(0, -.1, 0.05, 0.01)),
"World_map2.png", width=1920, height=1080, asp=0)
# save interactive plot
tmap_save(m2, "World_map.html")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.