0

I am trying to visulaise count data using tmap for the first time. Zero counts are informative and need to be displayed.

I have the following code:

Long<- c(149.942, 149.93583, 149.96217, 149.963, 149.96833, 
149.97233)
Lat <- c(-36.919, -36.8345, -36.92367, -36.81117, -36.97183, 
-36.96033)
count <- c(0, 0, 107, 0, 0, 20)
da<-data.frame(Long, Lat, count)
locations_sf3 <- st_as_sf(da, coords = c("Long", "Lat"))
ns<-locations_sf3
tm_shape(ns) +
 tm_bubbles(col = "gold", size = "count")+
tm_legend(outside = TRUE)

enter image description here

However, tm_bubbles removes the zeros. I have coded this in ggplot and displayed zeros but wanted to move to the more elegant tmap. the ggplot code:

ggplot(aes(longitude, latitude, size = sum))+
 annotation_map(map_data("world"))+
  geom_point(col="red",pch=16)+
 coord_quickmap()

Giving:

enter image description here

Any help to get this working in tmap would be greatly appreciated.

Tom
  • 199
  • 8
  • It seems that you need to convert `0` to `1` in order to allow tmap to show the "zero" data points. – jazzurro Jan 17 '20 at 02:18
  • thanks, that seems to get the zero count data on the map. Any hints on customising the legend to display the size of the zero (or 1) counts would be appreciated – Tom Jan 17 '20 at 02:45
  • Something like this for your custom legend? https://stackoverflow.com/questions/32890762/how-to-manipulate-tmap-legend – william3031 Feb 14 '20 at 03:48

0 Answers0