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

Error when trying to plot SpatialLinesDataFrame using tmap in R

I'm attempting to plot a SpatialLinesDataFrame using the R package tmap. However I keep getting this error message: Error in CPL_geos_is_empty(st_geometry(x)): Evaluation error: IllegalArgumentException: point array must contain 0 or >1…
3
votes
1 answer

Trying to plot in tmap shapefile with attribute

I am trying to work with municipality data in Norway, and I'm totally new to QGIS, shapefiles and plotting this in R. I download the municipalities from here: Administrative enheter kommuner / Administrative units municipalities Reproducible files…
Joanna
  • 33
  • 4
3
votes
1 answer

How to specify a single colour for rasters with tmap?

I would like to adjust the basic colour of a raster plotted with tmap, when there is only one value in the raster. Here is a very simple reproducible example: library(raster) library(tmap) a <- raster(matrix(sample(c(1, NA), 10000, replace = TRUE,…
Boris Leroy
  • 460
  • 4
  • 14
3
votes
2 answers

How to create a map with transparent background?

I'm trying to create and save a map with transparent background instead of a white (or any other color) one using the R package tmap. Apart from what's in the example below, I tried using bg.color = "transparent", bg.color = NA, and bg.color = NULL…
karpfen
  • 489
  • 8
  • 19
3
votes
0 answers

R tmap:: inner margins appear although set to zero

I am creating a map that consists out of 3 map panels. I have set the inner margins to zero in the tm_layout options for all maps, however depending on the dimensions of the output I still have empty white space inside the map frames. I can reduce…
Kanoet
  • 143
  • 1
  • 11
3
votes
1 answer

How to fix vertical space in crowded tmap legend [R]

How do I fix vertical space issues in tmap legends, like the ones shown in the linked base R example? (Vertical spaces in legend; y.intersp is not a recognized parameter by tmap_add_legend()) Basic tmap…
dad
  • 1,335
  • 9
  • 28
3
votes
2 answers

How to set the alpha based on a column?

Consider this example: library(dplyr) library(sf) library(tmap) d <- data_frame(one = c(1,1,2,1,1,1,1), two = c(1,1,2,1,1,1,1)) std <- st_as_sf(d, coords = c('one', 'two')) std %>% tm_shape() + tm_bubbles(alpha = 0.3) You can…
ℕʘʘḆḽḘ
  • 18,566
  • 34
  • 128
  • 235
3
votes
2 answers

How to add my data to tmap layer and draw a density world map?

I have a data set, df, in format as: Country Population US 1000 Germany 3000 Brazil 5000 France 6000 ...... I would like to treat Population as density and plot the density in gradient colors in the world…
HW-Scientist
  • 394
  • 2
  • 7
  • 20
3
votes
1 answer

R tmap: How to adjust the legend frame line width

I am trying to make a map with the cool tmap package and I cannot figure it out how to adjust the legend frame line width. I checked the impressive list of tm_layout arguments, but the closest I found was frame.lwd However,that refers to the frame…
Valentin_Ștefan
  • 6,130
  • 2
  • 45
  • 68
3
votes
2 answers

Customize tm_compass() background

In the code below, how do I set background color and transparency fortm_compass()as I can do for map title? library(tmap) library(dismo) ny.map <- gmap(x = "New York", zoom = 13, type = "satellite") print(tm_shape(shp = ny.map) + tm_raster()…
Manojit
  • 611
  • 1
  • 8
  • 18
3
votes
1 answer

Change the legend's language with qtm tmap

I try to make a simple choropleth map using tmap : library(tmap) data(World, rivers, metro) qtm(World, fill="HPI", fill.n=9, fill.palette="div", fill.auto.palette.mapping=FALSE, fill.title="Happy Planet Index", fill.id="name", format="World",…
Malta
  • 1,883
  • 3
  • 17
  • 30
3
votes
1 answer

Adding a column from a dataframe to a SpatialPolygon Dataframe

I've been trying to add a column of numerical data from a dataframe to a SpatialPolygon dataframe but every attempt leads to the latter dataframe being converted to a standard dataframe similar to the former. I needed to add the column so that I can…
LoriDori
  • 147
  • 2
  • 8
3
votes
1 answer

interactive map using tmap package with RMarkdown

I am trying to write a report about my program and to show my work using RMarkdown. However, the map that I am currently using is generated by tmap package. The shapefile can be downloaded here The way that I make it interactive using R is…
Hardian Lawi
  • 588
  • 5
  • 22
2
votes
0 answers

Label a map with lead lines/call out using tmap in R

I am trying to produce a map using the tmap library. I want to label all areas and use lead lines to label tiny areas. I'm looking for a line of code that works like ggrepel in ggplot2 or geom_sf_label_repel in the sf library but for tmap. Here is a…
Joke O.
  • 515
  • 6
  • 29
2
votes
1 answer

How to change the position of single label manually using tmap?

When I add the polygon labels to my maps using tm_text function it sometimes happens that some labels overlap. Is there any way to change the position of single labels manually avoiding they overlap? Here an example of the problem using data from…
Ramon_88
  • 109
  • 11