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
3 answers

Get more aggregate shapes from shapefile

As described in this previous question, I'm plotting German zip codes. The most granular level is 5-digit, e.g. 10117. I would like to draw boundaries defined on the two digit level around, while also keeping the granularity of the zip codes for…
ulima2_
  • 1,276
  • 1
  • 13
  • 23
2
votes
0 answers

tmap titles for multiple plots in RShiny application

I'm creating an RShiny application that is supposed to have four components, two tmaps across the top row and two gauges (from the C3 package) on the bottom row, from the data package I commented out. The plots are working fine but for some reason,…
2
votes
0 answers

Need to adjust the legend size and title position in tmap package of R?

I have produced the maps of spatRaster layers as shown in the top image. I want to increase the width of the legend by stretching it a bit longer horizontally (it should have a size similar/close to the combined size of the top three panels), so…
Mukhtar Abdi
  • 391
  • 1
  • 12
2
votes
0 answers

Problem with adding labels using tm_text function within tmap

I have created a great map using the code below but got a problem with labels. The labels overlaps with each other and become unreadable. How can I fix this? My map : Per65_Both <- tm_shape(nhmap) + tm_fill ("Per65", title="65+%",palette =…
MRR
  • 23
  • 2
2
votes
0 answers

How to display the legend only once when using tmap::tm_facets() in view mode?

I made a map using the tmap package. This map is displayed in view mode and has facets. I would like the legend to appear only once, outside of the graph/facets, at the bottom and stacked horizontally. I cannot share the original data but here is a…
Romain
  • 171
  • 11
2
votes
1 answer

Capture tmap bounding box as a Shiny input

I have a Shiny app with tmap and want the user's zoom and pan to update the data filter. For instance: require(tmap) require(shiny) require(dplyr) d =…
geotheory
  • 22,624
  • 29
  • 119
  • 196
2
votes
0 answers

tmap raster layer not rendering pixels full size

I'm trying to produce a basic heatmap and the grid pixels are rendering very small. require(tmap) require(dplyr) require(stars) d = data.frame(lon = rnorm(1e5, mean = -95.5, sd=4), lat = rnorm(1e5, mean = 37.5, sd=4)) |> …
geotheory
  • 22,624
  • 29
  • 119
  • 196
2
votes
1 answer

Editing a tmap data file in R

I'm new to using tmap. I'm using the default "World" map and I'm able to create a world map and color all the countries according to life expectancy simply using: library(tmap) library(sf) tm_shape(World) + tm_polygons("life_exp") But now, I've…
Jarvis
  • 31
  • 5
2
votes
0 answers

How to draw contour lines from a simple feature (i.e., column values) of an sf object

I have an sf polygon object and am wondering how can I draw contour lines based on the column values. What I want to realize is something like below (this map is credited to here). My data look like below. Please download the data from here. I want…
Yabin Da
  • 553
  • 5
  • 11
2
votes
1 answer

Changing data frame to sf object in R, so it can be plotted by tmap

How can i convert this example dataframe below. So it creates a spatial object that can be plotted by tmap? The data consists of two Local Authority District (UK) regions - cornwall and hartlepool. It also consists of corresponding metadata that I…
Sean
  • 47
  • 6
2
votes
0 answers

R, tmap: Legend with text both sides

I am trying to create a legend in Tmap that has text on both sides of the color classifications, as shown here: Minimal working example: library(tmap) data("World") tm_shape(World) + tm_polygons("HPI") Produces the standard legend with text…
micx274
  • 33
  • 4
2
votes
1 answer

How to label only one point in tmap in r?

In the example below I would like to have only the label for Ghana in the tm_text("name") layer showing. Any idea how to do this? Thank you for your help. library(tmap) data("World") tmap_mode("view") tm_shape(World) + tm_polygons("HPI",…
2
votes
0 answers

Making a dot density map with tmap package

I am trying to make a map using the tmap package, but i don't know the code to do a dot density map. The dataset i have consists of births, and i want to plot the number of births on each region of my map as dots (regions with higher number of…
2
votes
0 answers

How to Zoom out with tmap_mode "plot"

I created a world map using the code below. Right now, it shows the countries that have data. I want to be able to see zoomed out version of the world map in plot view. Insight on this issue will be appreciated. Thank you in…
Ani
  • 328
  • 1
  • 4
  • 13
2
votes
1 answer

tmap only plotting first polygon in sf geometry column

tmap is only plotting the first polygon in an sf geometry column, but plot() gets them all. Some github issues for tmap and leaflet mention something similar, but they were related to names in an sf geometry column (which the World data doesn't…
treysp
  • 663
  • 6
  • 17