# Wed Sep 02 22:42:20 2020 -
# 字符编码:UTF-8
# R 版本:R x64 4.0.2 for window 10
# cgh163email@163.com
# 个人笔记不负责任
# —— 拎了个梨🍐
rm(list=ls());gc()
.rs.restartR()
require(mapdeck)
## You need a valid access token from Mapbox
# key <- 'abc'
set_token( key )
# df <- read.csv(paste0( 'https://raw.githubusercontent.com/uber-common/deck.gl-data/master/', 'examples/3d-heatmap/heatmap-data.csv'))
df <- read.csv('heatmap-data.csv')
df <- df[ !is.na(df$lng), ]
df$weight <- sample(1:10, size = nrow(df), replace = T)
# Wed Sep 02 23:11:21 2020 ---基础---------------------------
mapdeck( style = mapdeck_style('dark'), pitch = 45 ) %>%
add_screengrid(
data = df
, lat = "lat"
, lon = "lng"
, weight = "weight",
, layer_id = "screengrid_layer"
, cell_size = 10
, opacity = 0.3
)
# Wed Sep 02 23:11:06 2020 --sf对象作图----------------------------
library(sfheaders)
sf <- sfheaders::sf_point( df, x = "lng", y = "lat")
mapdeck( style = mapdeck_style('dark'), pitch = 45 ) %>%
add_screengrid(
data = sf
# , weight = "weight", # 锁定大小
, layer_id = "screengrid_layer"
, cell_size = 10 # 格子大小
, opacity = 0.8 # 0~1,不透明度
)
1 map a mapdeck map object 一個mapdeck地圖對象
2 data data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system 圖層中要使用的數據。 所有坐標均應為EPSG:4326(WGS 84)坐標系
3 lon column containing longitude values 包含經度值的列
4 lat column containing latitude values 包含緯度值的列
5 polyline optional column of data containing the polylines, if using encoded polylines 如果使用編碼折線,則包含折線的數據的可選列
6 weight the weight of each value. Default 1 每個值的權重。 默認值1
7 aggregation one of 'min', 'mean', 'max', 'sum'. If supplied it specifies how the weights used. “最小”,“平均”,“最大”,“和”之一。 如果提供,則指定如何使用權重。
8 colour_range vector of 6 hex colours 6種十六進制顏色的向量
9 opacity opacity of cells. Value between 0 and 1. Default 0.8 細胞的不透明性。 介於0和1之間的值。默認值為0.8
10 cell_size size of grid squares in pixels. Default 50 網格正方形的大小(以像素為單位)。 默認值50
11 layer_id single value specifying an id for the layer. Use this value to distinguish between shape layers of the same type. Layers with the same id are likely to conflict and not plot correctly 指定圖層ID的單個值。 使用此值可以區分相同類型的形狀圖層。 具有相同ID的圖層可能會發生衝突並且無法正確繪製
12 update_view logical indicating if the map should update the bounds to include this layer 邏輯指示地圖是否應更新邊界以包括此圖層
13 focus_layer logical indicating if the map should update the bounds to only include this layer 邏輯指示地圖是否應將邊界更新為僅包括此圖層
14 digits number of digits for rounding coordinates 舍入坐標的位數