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.
446
questions
0
votes
0
answers
43
views
how to show raster cell values with tmap?
The code below plots raster cell values. How can I do the same with package tmap?
library(terra)
pai_sim <- rast(ncols=6, nrows=6,
xmin=1, xmax=60,
ymin=1, ymax=60,...
0
votes
0
answers
17
views
Toggle legend in tmap view mode
Is it possible to toggle the display of legend for tmaps in view mode? It seems possible in leaflet so seems like it should be possible with tmap
0
votes
0
answers
13
views
How to make a legend using tmap with large number of levels?
I am trying to create a map showing population density for local authority districts but I’m having some trouble creating a suitable legend.
I used this code:
tm_shape(merged_area_population_data) + ...
0
votes
0
answers
20
views
Figure labels and references for tmap (leaflet) maps in a Shiny markdown document
Is it possible to create figure labels, and reference them within text, for interactive tmap objects in a R markdown that will be rendered/hosted using shiny runtime to make an interactive document? ...
0
votes
1
answer
48
views
R: Convert sf polygon defined using lat/long to UTM
I have the following polygon, defined using degrees latitude/longitude:
## Define latitude/longitude
lats <- c(64.25086, 64.24937, 63.24105, 63.22868)
lons <- c(-140.9985, -136.9171, -137.0050, -...
0
votes
1
answer
28
views
How to represent different borders in tmap legend
my map looks similar to this one:
# import shapefile
shape_data <- system.file("shape/nc.shp", package="sf")
shape_data <- st_read(shape_data)
sample_data <- filter(...
0
votes
1
answer
53
views
How to force text displayed by the tm_text function of R's tmap to remain inside polygon?
I'm using the tm_text function in the tmap package (for R) to draw maps and I want to force the text that is displayed to remain inside the polygon that it refers to. How do I achieve this with this ...
0
votes
0
answers
23
views
Mapping mismatch between variables from the same grid cell structure + R
I created the following map with tmap.
The VCI and shp_union dataset were both created with the same grid cell structure.
However, when I map shp_union, some of the bubbles are mapped outside the grid ...
0
votes
1
answer
49
views
Converting latitude and longidue into multipolygon
I have been trying to convert the latitude and longitude into multipolygon object so that that I can use tmap library to plot it, but I am not able to that. Converting useing st_as_sf is not wroking, ...
0
votes
1
answer
58
views
i want to merge 2 databases with Talend Open Studio
my job is to merge 2 databases, one is on sql server and the other one is a metadata !! i used tmap to make the second database having the same schema as the first one !!
the 2 databases have id in ...
0
votes
1
answer
44
views
How to add relevant scale bars on inset maps using tmap
I used tmap to create the plot attached. However, I would like to add a scale bar to the inset map, but I haven't been able to figured out how to do that. Can someone please help me?
Here are the ...
-2
votes
1
answer
58
views
How do you add a raster layer ontop of another raster map in R
I've created a base map as seen in the document provided. In addition to this I've also made a combined raster file with Fs values that I wish to overlay over the basemap.
I was wondering how I can ...
-3
votes
1
answer
75
views
Converting latitude and longitude to coordindates
I manually entered latitude and longitude in my dataset in csv format and imported the dataset to R. I am trying convert the variable lat and lng into coordinates so that I can use tmap or geom_sf to ...
0
votes
0
answers
80
views
How to modify Morocco/Western Sahara boundaries in map_data of ggplot2?
I have been using ggplot2 to do something similar to this post: How can I fix an issue with Lesotho filling the same color as South Africa in ggplot2, using geom_polygon and polygon coordinates from ...
0
votes
0
answers
44
views
How to create an interactive map of stars/raster object with arbitrary crs?
Problem
I would like to create interactive maps of a regular grid that comes in a CRS which is not WGS84. In my case the CRS is EPSG:25833 which has unit metres.
Given the comment here, it does not ...
0
votes
1
answer
38
views
tmap w/ leaflet - can't get basemap to work, set zero
I am trying to make a map following this guide, and I am having some trouble trying to get a basemap underlaying the diagram.
I am using this code to make the map:
tm_shape(runsample) +
tm_fill(&...
0
votes
0
answers
36
views
'invalid color name' with tm_add_legend
Having another problem figuring out tmap. So I'm trying to make a legend manually so that I can control the title and label text, but when I use the col argument it gives me the error
Here's what my ...
0
votes
1
answer
37
views
tmap, ggplot and missing polygon (Barbados)
I am used to work with tmap plus ggplot with the dataset included in tmap: "World" but I just found out that it does not include Barbados for certain reason. I need the area and MULTIPOLYGON....
0
votes
1
answer
46
views
Unable to plot the census tracts using tmap
I am getting an error in plotting the census tract of New York using tmap. Below is an example and the error.
It requires API key which is free. Here is the link -
https://api.census.gov/data/...
0
votes
0
answers
21
views
add breaks to tm_bubbles/tm_symbol
I have the following map.
I would like to create breaks for the cumulated conflicts.
I wrote the following code but it does not work.
tm_shape(test) +
tm_polygons(col="vcidrought_type",
...
0
votes
0
answers
23
views
tmap + labels colors don't match the data
I created the following map. However, the labels in the legend don't match the data. I don't understand what goes wrong. I expected the pal colors to be ordered with the labels. So would do the data.
...
0
votes
1
answer
274
views
tm_symbols: how to control size?
I am new to tmap.
I am working with tm_dots and I want the size of dots to be determined by a numeric variable. So I wrote tm_dots(size="variable"). I would like to control manually the size ...
0
votes
1
answer
98
views
object 'x' not found when using tm_shape, but object exists?
I'm trying to make maps showing each country's score for a human rights index using tmap. tmap only has a few shapes that can be used ('nz' for New Zealand, 'world' for the whole world, and one or two ...
0
votes
0
answers
80
views
Talend create boolean rows on condition in Tmap
I have an Excel containing categories of company. In my dataset I want to add a boolean column telling if the categories is a start up or not. The column categorie is in string type.
Categorie
Bank
...
0
votes
0
answers
75
views
Adding two HH:mm time values in Talend Data Integration
I have got a requirement to push the data from excel to database.
Excel has few columns that are automated with formulas:
In the job, I am using tFileInputExcel >> tMap >> database. In ...
0
votes
0
answers
45
views
tmap Color in legend doesn't match the actual map
I tried to draw a map using tmap with the color palette in grey scale. However, I can not get the legend to match the actual color in the map.
Here are my codes:
tmap::tm_shape(ut_master_T10) +
...
1
vote
1
answer
95
views
TALEND STUDIO - Get number of Non-working Days between start_date and end_date using TMAP in Talend
I am a beginner in Talend and I need to achieve the following:
For example, I have two input tables in the TMAP component.
Table 1:
Start_Date
End_Date
25/8/2022
1/9/2022
Table 2 (Lookup Table):
...
1
vote
1
answer
38
views
Plotting large sf dataframe
I need to work with a 10minutes (1/12th degree) global grid of all land areas. The grid is generated in R using package (sf). The grid is to be limited to land areas of the world. Grid ID is needed ...
0
votes
1
answer
86
views
How to adjust the compass position on the map in R
I would like to adjust the compass position on the map. Note that part of the compass is joined to the scale, however, I would like to leave the compass slightly above the scale.
library(terra)
...
0
votes
1
answer
38
views
How to insert colors in a map made using the tmap function in R
I would like to insert the colors in the second map that uses the tmap function, as I did using the first code.
First code
library(terra)
library(geodata)
library(raster)
brz <- geodata::gadm(&...
3
votes
1
answer
81
views
Create a map of spain with lakes
I have a shapefile of water from Spain and boundaries shapefile of Spain.
boundaries shapefile called boundaries
and water shapfile is called water
boundaries <- st_read("boundaries_spain.shp&...
0
votes
1
answer
48
views
Why are my polygons and points from two different sources not rendering in tmap?
I am trying to create a map with a polygon layer and a point in tmap. The replication code and data can be found here.
My code starts like this and creates a map just fine:
###########################...
0
votes
0
answers
175
views
R tmap: Adjust line height in two-line legend title
Could you please help me with this problem? I want to put a legend title on two lines, and control legend placement in a figure that meets font size and figure size requirements. I am mapping a count ...
0
votes
2
answers
261
views
How to verify if a string contains at least two numbers in Talend?
Does anybody know how to verify if a string contains at least two numbers in Talend using the Tmap component?
Example: The string "46 W Street, New York, NY 10033" is true since I have "...
0
votes
0
answers
19
views
Viewport function clips the main map
I would like to include an inset map next to a main map. Here is the code that I use:
# Combine crude rate map (inset + main) =====
ut_map_cruderate
print(ut_map,
vp = viewport(
x = ...
0
votes
1
answer
55
views
How to transform a list of numbers into seperate elements talend tmap
I have a list of codes for each state as an input stored in a table.
What I want as output is this , using tmap transformations
This is the job I made but it doesn't seem to work correctly like I ...
0
votes
1
answer
70
views
Transform columns on Talend using TMAP
So I have this table as an input:
The "numero" column is either of "Type" 7 or 2.
What I want as an output is this
My tmap does not seem to work correctly. Can anybody suggest me ...
0
votes
0
answers
46
views
Create leaflet object from tmap_arrange
I'm using tmap to produce maps within an interactive RMarkdown report. In order to be able to utilize figure captions and figure numbers, I figured out that I need to create a leaflet object from the ...
-2
votes
1
answer
117
views
tmap crashes R on loading
I used tmap and it was working fine until two days ago. I opened a project where tmap was used and worked perfectly, and tmap crashed R on loading (library(tmap)). I use windows 11 and R studio. I ...
0
votes
0
answers
156
views
Problems installing R package 'tmap' in RStudio
I am running RStudio 3.6.0 in a cloud server (centos linux 7).
When trying to install package tmap the installation fails because of underlying version problems. There are many of them and I just list ...
0
votes
1
answer
69
views
R tmap not reacting to color palette in a shiny app
I have a shiny app that is not showing the points as the color palette. It just shows them black.
I would like the points to change color based on whether the value high or low.
How can I do this?
...
0
votes
0
answers
71
views
How to put an inset map in tmap in r
I'm trying to use the tmap package to create an inset map of a region of New Zealand, with a number of shapefile points on the zoomed in inset map. I've had a look online and found a couple of ...
0
votes
0
answers
23
views
Dealing with exclaves in R tmap
I have a shapefile that includes an exclave (area that is not connected to the continuous main part), which causes the map to look like
this
I tried to work around it by creating a dummy variable for ...
0
votes
0
answers
39
views
erase_water in as_dot_density failed
I'm trying to create a dasymetric dot density map using tmap. From the vignette, it was recommended to use erase_water() to remove water areas from the polygons prior to generating dots. However, when ...
2
votes
0
answers
26
views
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. ...
1
vote
0
answers
1k
views
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 ...
0
votes
0
answers
46
views
All tmap::qtm() plot titles are appearing in a single plot rather than their own
I am currently writing a .Rmd (R markdown document) on downloading and visualising the Local Authority Districts (LADs) and transport regions of the UK within Rstudio.
> R.version
_ ...
1
vote
1
answer
116
views
tmap_arrange output quality in R markdown
Is there any way to control the output resolution when using tmap_arrange?
Example using the shape files of Dutch regions from the cbs api and assigning population data (random for simplicity). Each ...
0
votes
0
answers
70
views
Full scale in tmap so to not confuse when comparing two maps
Is it possible to easily edit the maps to that the values in the scales are equal? With the pictures of the two maps produces with the code you can see that although there has been an increase in the ...
0
votes
1
answer
104
views
Apply linear stretch to Landsat 8 images in the tmap R package
I have a Landsat 8 dataset downloaded from the USGS. I import into R using the following code:
library(raster)
library(tmap)
B1 <- raster("LC08_L2SP_166072_20210819_20210827_02_T1_SR_B1.TIF&...