Questions tagged [tmap]

tmap is an actively maintained open-source R-library for drawing thematic maps, written by Martijn Tennekes. The API is based on the Layered Grammar of Graphics, and resembles the syntax of ggplot2, a popular R-library for drawing charts.

tmap is an actively maintained open-source R-library for drawing thematic maps, written by Martijn Tennekes. The API is based on A Layered Grammar of Graphics by Hadley Wickham and resembles the syntax of , a popular R-library for drawing charts.

Repositories

Vignette

Presentation

Other resources

487 questions
7
votes
2 answers

Producing an inset map with the tmap package in R

I am trying to produce an inset map of London alongside a larger map of the UK. I'm using the package "tmap" which I have found to be an excellent package and particularly easy to move to having used ggplot2 for a while. However, the documentation…
SJPG
  • 83
  • 1
  • 7
6
votes
1 answer

How to put title of a map outside of the panel (tmap package)

I'm plotting a simple map in R and I'm stuck with this problem: the title is overlapping the plot and I don't know how to put it outside of the panel. With ggplot2 I can do this easily with plot.title.position option in theme function, since tmap…
Rik Ferreira
  • 161
  • 1
  • 10
6
votes
3 answers

Small multiple maps with geom_sf at the same spatial scale

I would like to plot a figure with small multiple maps using ggplot2::geom_sf. The challenge here is how to do this keeping all maps centered in the image and at the same spatial scale. Here is the problem (data for reproducible example below): A…
rafa.pereira
  • 13,251
  • 6
  • 71
  • 109
6
votes
1 answer

How to reverse the diverging color palette in R Tmap?

I'm using the R package Tmap to create choropleths of a variable that is sometimes positive and sometimes negative. The default diverging color palette shows positive values in green and negative values in red. I would like to reverse this, to show…
user9831776
6
votes
1 answer

Marker cluster in tmap

I am currently using tmap to create interactive maps. Since the results are quite cluttered at initial zoom (see image below), I would like to implement marker clusters. I know leaflet allows using marker clusters by adding the parameter…
ccamara
  • 1,141
  • 1
  • 12
  • 32
5
votes
0 answers

create animation of vehicle moving along a route "with timeline of events"

This is a followup question on How to create animation of vehicle moving form A to B along a route?. I could learn how to animate vehicles moving from A to B along the route. Thanks for the help! But is it possible to make a self explanatory video…
SiH
  • 1,378
  • 4
  • 18
5
votes
2 answers

Remove legend in tmap in R

I have a simple question: How does one remove an automatically added legend in tmap in R? In this case, I want to remove that legend on the right, depicting 'level'. Here's what I've tried: tm_shape(densities$polygons)+ tm_polygons(col='level',…
imguessing
  • 377
  • 1
  • 3
  • 9
5
votes
1 answer

Change plotting order of categories of data in tmap map R

I am plotting some spatial data in R using the tmap package. I define breaks and plot color in the tm_dots function. I'd like to be able to define the plot order of the categories so that they are defined by the category (highest category on top,…
user29609
  • 1,991
  • 18
  • 22
5
votes
1 answer

How to adjust color palette with customized breaks in tmap?

I would like to plot 1950 world population in density map with tmap package. And I break the population data into 22 categories manually, and fill with different color for each category. My code is: library(tmap) data(World) map <-…
HW-Scientist
  • 394
  • 2
  • 7
  • 20
5
votes
1 answer

Draw multiple object of class tmap with just one common legend

I am trying to draw multiple maps from the tmap-package using tm_shape() and tm_layout() in one page using grid.layout() from the grid-package. I would like to plot only one common legend for all maps, similar to the example shown here: ggplot…
Erich
  • 93
  • 1
  • 6
5
votes
3 answers

Plot 2 tmap objects side-by-side

Example: I want to plot two tmap plots side by side, which are generated by this code. library(tmap) library(gridExtra) data(World) plot1= tm_shape(World, projection = "merc") + tm_layout("", inner.margins=c(-1.72, -2.05, -0.75, -1.56)) + …
user2030503
  • 3,064
  • 2
  • 36
  • 53
4
votes
0 answers

Use leafsync and leafletProxy together on shiny map

I'm trying to show two synced maps on a shiny app that show densities of species in two different samples based on inputs species and year. I have it working using leafsync, but not set up to use leaflet proxies, so every time I change an input, the…
Jake L
  • 987
  • 9
  • 21
4
votes
0 answers

tmap: incorporate inset map with tmap_arrange

How to create and save inset maps with tmap is covered in several tutorials, e.g. here. However, I would like to merge several maps into one file, as facilitated by tmap_arrange. To my understanding, the way inset maps are created in tmap involves…
M.Teich
  • 575
  • 5
  • 22
4
votes
1 answer

Is there any way to customize legend histogram using tm_layout

Please see the map I drew below using the tmap package. I did not any find parameters that I can use to customize the font of the histogram legend. From the code below, you can see that I've already set the legend.text.fontface = 'bold'. However,…
Yabin Da
  • 553
  • 5
  • 11
4
votes
1 answer

Reactivity problem while using renderTmap within R/shiny

I'm trying to integrate a tmap into a shiny app and doing so I have encountered a reactivity problem. I get an error implying that the function renderTmap() does not create a reactive environment (while "classic" renderXXX() functions do). Here is…
lvaudor
  • 113
  • 5
1
2
3
32 33