根据地图中的列值绘制条形图

时间:2019-04-07 05:25:12

标签: r r-leaflet deck.gl mapdeck

我正在使用地图平台绘制近10万个点,是否有可能代替点,而是根据安装的列的值显示条形图

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

我也熟悉传单,因此也可以使用它。

1 个答案:

答案 0 :(得分:1)

使用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