8 Exporting maps

Once you have made a map and are satisfied with its appearance, it is straightforward to export the map from R Studio to a local directory on your computer, where you can then embed your map in papers, projects, presentations, or websites.

The easiest way to export maps is by using the tmap_save() function. This function allows users to specify the desired dimensions and resolution of the exported map, among other things. For our purposes, we’ll simply export the map assigned to traffic_bias_map_continuous_labeled using the default settings. Below, the first argument is the name of the map object we’d like to export; here, that is traffic_bias_map_continuous_labeled. The second argument is the desired file name and extension; it is possible to pick any number of extensions, such as PDF, jpeg, and png. Here, we’ll export the map as a .png file.

tmap_save(traffic_bias_map_continuous_labeled, 
          "traffic_bias_map_continuous_labeled.png")
## Map saved to /Users/adra7980/Documents/git_repositories/intro_GIS/traffic_bias_map_continuous_labeled.png
## Resolution: 2448.943 by 1800.777 pixels
## Size: 8.163142 by 6.002591 inches (300 dpi)

Because we didn’t specify the path to a directory in the second argument, the map will be exported to our working directory.

Note that if we’d like to export a dynamic/interactive map, we can use the same code as above; the only difference is that we would use an “html” extension. The interactive map would then be exported to our working directory as an html file, which can then easily be embedded on a website.