tmap

R - Adding dots to map in tmap

别等时光非礼了梦想. 提交于 2019-12-11 16:43:16
问题 My map-making code generates a map based on census data and plots important points as a tm_dots() layer. What I'd like to be able to do is differentiate between the types of dots (e.g. if the location is "Informal" or "Commercial"). tm_shape(bristol) + tm_fill("population", palette = "YlOrRd", auto.palette.mapping = TRUE, title = "Bristol Population", breaks = c(0,5,10,15,20,25), colorNA = "darkgrey") + tm_borders("grey25",alpha = 0.7, lwd = 0.1) + tm_dots("n", size=0.1,col="green", shapeNA =

R: Mapping positive and negative numbers with different colors

◇◆丶佛笑我妖孽 提交于 2019-12-11 02:26:09
问题 I'm a journalist working to map the counties where the number of black farmers increased or decreased between 2002 and 2012. I am using R (3.2.3) to process and map the data. I've been able to map the whole range of county-level gains and losses—which goes from negative 40 to positive 165—in a single color, but this makes it hard to see the pattern of gains and losses. What I'd like to do is make the losses all variations of a single color (say, blue), and render gains in variations of a

line connecting label text and point in tmap plot

大兔子大兔子 提交于 2019-12-10 23:05:35
问题 i'm doing a tmap plot with a shape file, and i want to be plotting several points for which i have long-lat coordinates onto the shape file. i've got the plot working just fine, however there are too many points on the map, meaning that the label text for different points is overlapping, and is just not particularly legible in general. here's what the plot currently looks like. i would really like for the text in the plot to be outside of the actual map, and to be connected to the points in

Adding fixed size breaks with tmap tm_bubble

喜夏-厌秋 提交于 2019-12-10 22:29:34
问题 I am trying to create a tmap bubbleplot where the size and color aesthetics have the same fixed breaks. Setting the style = "fixed" and breaks = c(-Inf, seq(-10, 10, by = 2.5), Inf) is producing the desired result for the color variable, but the size variable remains unchanged. I am dealing with data that has positive and negative values, so I'm using a diverging color palette with the color aesthetic. I'm using the absolute value of this variable when plotting its size though. I would like

How to join Spatial data with Dataframe so it can be displayed with Tmap?

∥☆過路亽.° 提交于 2019-12-08 11:46:30
问题 Short version: when executing the following command qtm(World, "amount") I get the following error message: Error in $<-.data.frame ( *tmp* , "SHAPE_AREAS", value = c(653989.801201595, : replacement has 177 rows, data has 175 Disclaimer: this is the same problem I used to have in this question, but if I'm not wrong, in that one the problem was that I had one variable on the left dataframe that matched to several variables on the right one, and hence, I needed to group variables on right

Tmap Error - replacement has [x] rows, data has [y]

天涯浪子 提交于 2019-12-02 08:37:41
Short version: when executing the following command qtm(countries, "freq") I get the following error message: Error in $<-.data.frame ( *tmp* , "SHAPE_AREAS", value = c(652270.070308042, : replacement has 177 rows, data has 210 Disclaimer: I have already checked other answers like this one or this one as well as this explanation that states that usually this error comes from misspelling objects, but could not find an answer to my problem. Reproducible code: library(rgdal) library(dplyr) library(tmap) # Load JSON file with countries. countries = readOGR(dsn = "https://gist.githubusercontent.com

Plot 2 tmap objects side-by-side

冷暖自知 提交于 2019-12-01 22:22:58
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)) + tm_borders(alpha = 0.3, lwd=2) plot2= tm_shape(World, projection = "merc") + tm_layout("", inner.margins=c(-1.72, -2.05, -0.75, -1.56)) + tm_borders(alpha = 0.3, lwd=2) plot1 and plot2 work fine as single stand-alone plots: Problem: I have problems to put both plots side-by-side. I tried: grid.arrange(plot1, plot2) throughs an error Error in arrangeGrob(...,

ggplot/mapping US counties — problems with visualization shapes in R

旧时模样 提交于 2019-11-28 18:28:57
So I have a data frame in R called obesity_map which basically gives me the state, county, and obesity rate per county. It looks more or less like this: obesity_map = data.frame(state, county, obesity_rate) I'm trying to visualize this on the map by showing various obesity rates per county throughout the US with this: us.state.map <- map_data('state') head(us.state.map) states <- levels(as.factor(us.state.map$region)) df <- data.frame(region = states, value = runif(length(states), min=0, max=100),stringsAsFactors = FALSE) map.data <- merge(us.state.map, df, by='region', all=T) map.data <- map

ggplot/mapping US counties — problems with visualization shapes in R

耗尽温柔 提交于 2019-11-27 11:23:00
问题 So I have a data frame in R called obesity_map which basically gives me the state, county, and obesity rate per county. It looks more or less like this: obesity_map = data.frame(state, county, obesity_rate) I'm trying to visualize this on the map by showing various obesity rates per county throughout the US with this: us.state.map <- map_data('state') head(us.state.map) states <- levels(as.factor(us.state.map$region)) df <- data.frame(region = states, value = runif(length(states), min=0, max