4 Exporting Maps from R Studio

First, let’s export our print map to our working directory, using the tmap_save function. The first argument is the name of the object to be exported, while the second argument is the desired name and extension of the exported file containing the map. For example, if we wanted to export the map as a png file, we would use the following:

# Writes print map ("usa_trifecta_map") to working directory as png file
tmap_save(usa_trifecta_map, "usa_trifecta_map_export.png")
## Map saved to /Users/adra7980/Documents/git_repositories/gistools_qda/usa_trifecta_map_export.png
## Resolution: 2929.035 by 1505.615 pixels
## Size: 9.76345 by 5.018718 inches (300 dpi)

If you want to export a webmap, use the same functions and arguments, but make sure to use an html extension for the output files; an interactive map will be saved to your working directory, which you can then embed on a website.

# Writes webmap to working directory as html file
tmap_save(usa_trifecta_map, "usa_trifecta_map_unshifed.html")
## Credits not supported in view mode.
## legend.postion is used for plot mode. Use view.legend.position in tm_view to set the legend position in view mode.
## Interactive map saved to /Users/adra7980/Documents/git_repositories/gistools_qda/usa_trifecta_map_unshifed.html