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
2
votes
1 answer

How to plot global rasters with tmap in Robinson projection without duplicated areas?

I've been plotting some global rasters lately using mainly raster and tmap. I'd like to plot the maps in Robinson projection instead of lat-lon. Simple projection to Robinson however duplicates some areas on the edges of the map as you can see from…
vdoe
  • 33
  • 4
2
votes
3 answers

Saving a Tmap plot in shiny

I want to add a feature for users to export a map, produced by Tmap, in Shiny. I understand that tmap converts the map to leaflet but it doesn't work with mapview::mapshot as many answers give for saving Leaflet maps in Shiny. None of the following…
nd37255
  • 248
  • 1
  • 9
2
votes
1 answer

how to manually change continuous scale color in tmap in R

How can I manually determine the colors on a continuous scale in tmap? For example, I am working with a map similar to the one below: data(World) World$gdp_cap_est2 <- World$gdp_cap_est -100000 tm_shape(World) + tm_polygons(col="gdp_cap_est2", …
Sharif Amlani
  • 1,138
  • 1
  • 11
  • 25
2
votes
0 answers

Spacing out legend keys using tmap/ggplot2 in R

I'm trying to produce a map using either the tmap or ggplot2 packages and need to follow some internal design guidelines which state that legend keys should be spaced out and rectangular in shape. I have tried tmap but the legend keys are square…
Gakku
  • 337
  • 2
  • 8
2
votes
2 answers

Applying a mask to a spatial raster in R?

I would like to mask my background map using a shapefile representing a regional boundary. To do this I have read a spatial raster into Rstudio using read_osm library(sp) library(tmaptools) HB_map <- spData::nz %>% filter(Name=="Hawke's Bay") %>%…
Simon
  • 295
  • 1
  • 4
  • 12
2
votes
2 answers

R tmap modify legends dynamically to prevent overlapping legend values

Is there a way to prevent overlapping values in legends in tmap dynamically? Take this example: library(tmap) data("World") tm_shape(World) + tm_polygons("HPI", n=7) The legend does not make it clear what category values of 15, 20, 25, 30, 35 or 40…
Chris
  • 1,197
  • 9
  • 28
2
votes
1 answer

Multipler Layers on TMAP

I am trying to make an interactive map with different layers in which the user can pick one of 8 different layers. The shape for all the layers is the exact same, the only thing changes is the column. Ideally I would want something like this, but…
Aaron Walton
  • 150
  • 1
  • 10
2
votes
1 answer

Align Legend Title in tmap

Is it possible to center the legend title in tmap? Utilizing the first example from the tmap getting started vignette: library(tmap) data("World") tm_shape(World) + tm_polygons("HPI") yields but I want: I have scoured the documentation for…
Bjørn Kallerud
  • 979
  • 8
  • 23
2
votes
1 answer

Making multiple maps in R using tmap

I'm relatively new to R and trying to create multiple geographic maps. I already managed to make one map and customise it the way it should be. However, I need to make 100+ similar maps with only one difference: the input of the thematic color. My…
David
  • 31
  • 5
2
votes
2 answers

Facet Map with tmap

I am trying to create faceted maps with the "tmap" package. My data contains a lot of missing countries. When I run the code below, the output shows a lot of missing countries. How can get the plot to show missing countries? library(tmap) …
RawisWar
  • 29
  • 4
2
votes
1 answer

Creating multiple density maps with same extent

I am trying to create density maps (rasters) from points using the smooth_map function from the tmaptools package. I would like to create one raster for each factor level of a variable (var) in my dataframe (df). All rasters should have the same…
albren
  • 109
  • 1
  • 1
  • 8
2
votes
2 answers

Remove / customize facets borders in tmap (tm_facets)

I created a plot with multiple facets, thanks to tmap (R package) and tm_facets. I would like to remove the borders of the facets titles (i.e. the black rectangles on top of each map), but I can't figure out how. Here is an…
Sgt Cheddar
  • 47
  • 1
  • 7
2
votes
1 answer

How to limit legend width with an expression in the title in tmap?

I have encountered some unexpected behavior in the tmap library and was wondering if there is a way around it. When producing a map with an expression in the legend title, the legend becomes too wide for some reason. Here's some code to show what I…
karpfen
  • 489
  • 8
  • 19
2
votes
1 answer

zoom and crop a map with tmap

I am trying to prepare an inset map to give a reference of the geographic location of Bhutan. I would like a map that fills the box, in which part of India, China, Bangladesh are visible and NOT the whole Asian continent. I am using the following…
JPV
  • 323
  • 2
  • 10
2
votes
1 answer

Trouble with error code: "Error: Fill argument neither colors nor valid variable name(s)"

I am trying to make a map with tmap and when I try to view it, this error code comes up: Error: Fill argument neither colors nor valid variable name(s) Here is my code. tm1=tm_shape(myshptime1)+ tm_polygons("zeta.x",style="pretty", …
Emma
  • 31
  • 1
  • 4