3D Barplot visualization on leaflet map in R

2020-06-06 01:56发布

I am using R and Leaflet (in a shiny app). I have point data which I want to visualize through a 3D plot on a map - like this: https://slipiste.wordpress.com/2015/09/29/3d-bar-plot-on-a-map-in-r/ Understandable how to do that if not done on leaflet. But how to do plot that on a leaflet map? Is there a way to do that?

They way I see it would have to overlay a shapefile (transparent) over my leaflet map and plot the 3D Barplot on that shapefile. However, that seems like a messy workaround. But, I did not find any websites on that topic. Any hints?

1条回答
叛逆
2楼-- · 2020-06-06 02:49

A few years on library(mapdeck) lets you plot a 3D bars on a map

library(mapdeck)

set_token("MAPBOX_TOKEN") ## you'll need an API token

df <- read.csv(paste0(
  'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/',
  'examples/3d-heatmap/heatmap-data.csv'
))

mapdeck(
  style = mapdeck_style('dark')
  , pitch = 45 
  ) %>%
  add_grid(
    data = df[1:30000, ]
    , lat = "lat"
    , lon = "lng"
    , cell_size = 1000
    , elevation_scale = 50
    , layer_id = "grid_layer"
  )

enter image description here

And from v0.2.1006 you can use the add_column() function

查看更多
登录 后发表回答