0

I am trying to make a map with hotels in las vegas. I have all the coordinates. I also made a map with a dot at the 'hotel points'. But these dots are all black. I need every hotel (dot) to be another color.enter image description here

As you can see, all the dots (hotels) are black.. This is my code:

df_hotels <- df_joinall %>% 
  group_by(hotel_name) 

df <- st_as_sf(df_hotels, coords = c("Longitude","Latitude"))

tmap_mode("view")+

tm_basemap("OpenStreetMap") +

tm_shape(df) +
tm_dots(popup.format = list(text.align = "center"), size = 0.5, alpha = 0.7)

Does anyone has suggestions on how to give every point (hotel) another color

Luuuuuuk
  • 43
  • 4

1 Answers1

0

To have the points colored you need to map the col aesthetic to a column of your data frame. Note that {tmap} requires column names enclosed in quotation marks.

Your example is not exactly reproducible, but I expect this to work:

df_hotels <- df_joinall %>% 
  group_by(hotel_name) 

df <- st_as_sf(df_hotels, coords = c("Longitude","Latitude"))

tmap_mode("view")+

tm_basemap("OpenStreetMap") +

tm_shape(df) + tm_dots(col = "hotel_name", size = 0.5, alpha = 0.7)
Jindra Lacko
  • 7,814
  • 3
  • 22
  • 44
  • Although my code was not reproducible this is exactly what I needed! This generates some kind of a legend and makes all the different (in this case) hotels another color. – Luuuuuuk Dec 05 '19 at 07:53