This event has ended. View the official site or create your own event → Check it out
This event has ended. Create your own
View analytic
Thursday, July 6 • 2:42pm - 3:00pm
Exploring and presenting maps with **tmap**

Sign up or log in to save this to your schedule and see who's attending!

Keywords: Visualisation, maps, interaction, exploration
Webpages: https://CRAN.R-project.org/package=tmap, https://github.com/mtennekes/tmap
A map tells more than a thousand coordinates. Generally, people tend to like maps, because they are appealing, recognizable, and often easy to understand. Maps are not only useful for navigation, but also to explore, analyse, and present spatial data.
The tmap package offers a powerful engine to visualize maps, both static and interactive. It is based on the Grammar of Graphics, with a syntax similar to ggplot2, but tailored to spatial data. Layers from different shapes can be stacked, map legends and attributes can be added, and small multiples can be created.
An example of a map is the following. This maps consists of a choropleth of Happy Planet Index values per country and a dot map of large world cities on top. Alternatively, a choropleth can also be created with qtm(World, "HPI").
library(tmap) data(World, metro) tm_shape(World) + tm_polygons("HPI", id = "name") + tm_text("name", size = "AREA") + tm_shape(metro) + tm_dots(id = "name") + tm_style_natural() Interaction with charts and maps is not considered as a nice extra feature anymore, of which users will say “wow, this is interactive!”. To the contrary, users will expect charts and maps to be interactive, especially when published online. Also in R, interaction has become common ground, especially since the introduction of shiny and htmlwidgets. However, the increase of interactive maps does not mean the end of static maps. Newspapers, journals, and posters still rely on printed maps. To design a static thematic map that is appealing, informative, and simple is a special craft.
There are two modes in which maps can be visualized: "plot" for static plotting and "view" for interactive viewing. Users are able to switch between these modes without effort. The choropleth above is reproduced in interactive mode as follows:
tmap_mode("view") last_map() For lazy users like me, the code ttm() toggles between the two modes. The created maps can be exported to static file formats, such as pdf and png, as well as interactive html files. Maps can also be embedded in rmarkdown documents and shiny apps.
save_tmap(filename = "map.png", width = 1920) save_tmap(filename = "index.html") Visualization of spatial data is important troughout the whole process from exploration to presentation. Exploration requires short and intuitive coding. Presentation requires full control over the map layout, including color scales and map attributes. The tmap package facilitates both exploration and presentation of spatial data.

avatar for Martijn Tennekes

Martijn Tennekes

Data scientist, Statistics Netherlands (CBS)
Data visualization is my thing. Author of R packages treemap, tabplot, and tmap.

Thursday July 6, 2017 2:42pm - 3:00pm
4.02 Wild Gallery

Attendees (159)