rr-leafletdeck.glmapdeck

draw a bar based on a value of column in a map


I am using map deck to draw nearly 100K points, is it possible instead of a dot, show a bar based on a value of a column installed

library(mapdeck)
library(htmlwidgets)
dataset =data.frame(stringsAsFactors=FALSE,
           x = c(143.4865219, 143.4865241, 143.4865264, 143.4865286,
                 143.4865305, 143.4865327),
           y = c(-34.7560602, -34.7561332, -34.7562088, -34.7562818,
                 -34.7563453, -34.7564183),
   installed = c("yes", "yes", "yes", "no", "no", "no")
)
MAPBOX_API_KEY = "xxxxxxxxxx"
test = mapdeck( token = MAPBOX_API_KEY ) %>%
      add_scatterplot(dataset,lon="x",lat="y")%>%
      mapdeck_view(location=center,pitch = 45,zoom=13)
#saveWidget(test, file="C:/Users/mimoune.djouallah/mapdeck.html")
test

I am familiar with leaflet too, so I can use it too, if it can do that.


Solution

  • using the dev version of mapdeck

    library(mapdeck)
    library(dplyr)
    dataset =data.frame(stringsAsFactors=FALSE,
                        x = c(143.4865219, 143.4865241, 143.4865264, 143.4865286,
                              143.4865305, 143.4865327),
                        y = c(-34.7560602, -34.7561332, -34.7562088, -34.7562818,
                              -34.7563453, -34.7564183),
                        installed = c("yes", "yes", "yes", "no", "no", "no")
    )
    center=c(mean(dataset$x),mean(dataset$y))
    
    MAPBOX_API_KEY ="xxxxxxx"
    test = mapdeck( token = MAPBOX_API_KEY ) %>%
      add_column(filter(dataset,installed=="yes"),
                 lon="x",
                 lat="y",
                 elevation = 3,
                 disk_resolution = 5
                 , radius = 0.9)%>%
      add_scatterplot(filter(dataset,installed=="no"),
                      lon="x",
                      lat="y")%>%
      mapdeck_view(location=center,pitch = 45,zoom=14)
    test