# Wed Sep 02 20:39:27 2020 -
# 字符編碼:UTF-8
# R 版本:R x64 4.0.2 for window 10
# cgh163email@163.com
# 個(gè)人筆記不負(fù)責(zé)任
# —— 拎了個(gè)梨??
rm(list=ls());gc()
.rs.restartR()
require(mapdeck)
# key <- 'abc'
set_token( key )
# Wed Sep 02 20:44:34 2020 -加載地圖矢量多邊形-----------------------------
library(geojsonsf)
sf <- geojsonsf::geojson_sf("https://geo.datav.aliyun.com/areas_v2/bound/440000_full.json")
names(sf)
# Wed Sep 02 20:44:58 2020 --作圖
mapdeck(
style = mapdeck_style('dark')
) %>%
add_polygon(
data = sf
, layer = "polygon_layer"
# , fill_colour = "name" # 填色參數(shù)經(jīng)常出錯(cuò)
)
# Wed Sep 02 20:45:34 2020 ---自帶地圖數(shù)據(jù)演示---------------------------
df <- melbourne ## 具有編碼多義性的data.frame
df$elevation <- sample(100:5000, size = nrow(df))
df$info <- paste0("<b>SA2 - </b><br>",df$SA2_NAME)
mapdeck(pitch = 45,
style = mapdeck_style('dark')
, location = c(145, -38)
, zoom = 8
) %>%
add_polygon(
data = df
, polyline = "geometry" # 不影響
, layer = "polygon_layer" # 不影響
# , fill_colour = "SA2_NAME" # 填色經(jīng)常出錯(cuò)
, elevation = "elevation" # 高程倍數(shù)
, tooltip = 'info' # 備注信息
, legend = T # 圖例湖饱?
,auto_highlight = T # 自動(dòng)高亮鼠標(biāo)位置
)
空格分隔的表格:
1 map a mapdeck map object 一個(gè)mapdeck地圖對(duì)象
2 data data to be used in the layer. All coordinates are expected to be EPSG:4326 (WGS 84) coordinate system 圖層中要使用的數(shù)據(jù)。所有坐標(biāo)均應(yīng)為EPSG:4326(WGS 84)坐標(biāo)系
3 polyline optional column of data containing the polylines, if using encoded polylines 如果使用編碼折線杀捻,則包含折線的數(shù)據(jù)的可選列
4 stroke_colour variable of data or hex colour for the stroke. If used, elevation is ignored. If using a hex colour, use either a single value, or a column of hex colours on data 筆畫的數(shù)據(jù)變量或十六進(jìn)制顏色井厌。如果使用,則忽略高程水醋。如果使用十六進(jìn)制顏色旗笔,請?jiān)跀?shù)據(jù)上使用單個(gè)值或一列十六進(jìn)制顏色
5 stroke_width width of the stroke in meters. If used, elevation is ignored. Default 1. 筆畫的寬度(以米為單位)。如果使用拄踪,則忽略高程蝇恶。默認(rèn)值1。
6 stroke_opacity Either a string specifying the column of data containing the opacity of each shape, or a single value in [0,255], or [0, 1), to be applied to all the shapes. Default 255. If a hex-string is used as the colour, this argument is ignored and you should include the alpha on the hex string 指定包含每個(gè)形狀的不透明度的數(shù)據(jù)列的字符串惶桐,或者是[0,255]或[0撮弧,1)中的單個(gè)值潘懊,將應(yīng)用于所有形狀。默認(rèn)值255贿衍。如果將十六進(jìn)制字符串用作顏色授舟,則將忽略此參數(shù),并且應(yīng)在十六進(jìn)制字符串中包含alpha
7 fill_colour column of data or hex colour for the fill colour. If using a hex colour, use either a single value, or a column of hex colours on data 數(shù)據(jù)列或十六進(jìn)制顏色作為填充色贸辈。如果使用十六進(jìn)制顏色释树,請?jiān)跀?shù)據(jù)上使用單個(gè)值或一列十六進(jìn)制顏色
8 fill_opacity Either a string specifying the column of data containing the opacity of each shape, or a single value in [0,255], or [0, 1), to be applied to all the shapes. Default 255. If a hex-string is used as the colour, this argument is ignored and you should include the alpha on the hex string 指定包含每個(gè)形狀的不透明度的數(shù)據(jù)列的字符串,或者是[0,255]或[0擎淤,1)中的單個(gè)值奢啥,將應(yīng)用于所有形狀。默認(rèn)值255嘴拢。如果將十六進(jìn)制字符串用作顏色桩盲,則將忽略此參數(shù),并且應(yīng)在十六進(jìn)制字符串中包含alpha
9 elevation the height the polygon extrudes from the map. Only available if neitherstroke_colour or stroke_width are supplied. Default 0 多邊形從地圖突出的高度席吴。僅在未提供stroke_colour或stroke_width時(shí)可用赌结。默認(rèn)值0
10 tooltip variable of data containing text or HTML to render as a tooltip 包含文本或HTML的數(shù)據(jù)變量以呈現(xiàn)為工具提示
11 auto_highlight logical indicating if the shape under the mouse should auto-highlight 邏輯指示鼠標(biāo)下方的形狀是否應(yīng)自動(dòng)突出顯示
12 elevation_scale elevation multiplier. 高程乘數(shù)。
13 highlight_colour hex string colour to use for highlighting. Must contain the alpha component. 用于突出顯示的十六進(jìn)制字符串顏色孝冒。必須包含alpha分量柬姚。
14 light_settings list of light setting parameters. See light_settings 燈光設(shè)置參數(shù)列表。參見light_settings
15 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的單個(gè)值迈倍。使用此值可以區(qū)分相同類型的形狀圖層伤靠。具有相同ID的圖層可能會(huì)發(fā)生沖突并且無法正確繪制
16 id an id value in data to identify layers when interacting in Shiny apps. 數(shù)據(jù)中的ID值,以在“閃亮”應(yīng)用程序中進(jìn)行交互時(shí)識(shí)別圖層啼染。
17 palette "string or matrix. String will be one of colourvalues::colour_palettes(). A matrix must have at least 5 rows, and 3 or 4 columns of values between [0, 255], where the 4th column represents the alpha. You can use a named list to specify a different palette for different colour options (where available), e.g. list(fill_colour = "viridis", stroke_colour = "inferno")" “字符串或矩陣宴合。字符串將是colourvalues :: colour_palettes()之一。矩陣必須至少包含5行迹鹅,且[0卦洽,255]之間的值包含3或4列,其中第4列表示Alpha斜棚。您可以使用命名列表為不同的顏色選項(xiàng)(如果有)指定不同的調(diào)色板阀蒂,例如list(fill_colour =“ viridis”,stroke_colour =“ inferno”)“
18 na_colour hex string colour to use for NA values 用于NA值的十六進(jìn)制字符串顏色
19 legend either a logical indiciating if the legend(s) should be displayed, or a named list indicating which colour attributes should be included in the legend. 邏輯指示是否應(yīng)顯示圖例弟蚀,或者是一個(gè)命名列表蚤霞,該列表指示應(yīng)在圖例中包括哪些顏色屬性。
20 legend_options A list of options for controlling the legend. 用于控制圖例的選項(xiàng)列表义钉。
21 legend_format A list containing functions to apply to legend values. See section legend 包含要應(yīng)用于圖例值的函數(shù)的列表昧绣。參見圖例
22 update_view logical indicating if the map should update the bounds to include this layer 邏輯指示地圖是否應(yīng)更新邊界以包括此圖層
23 focus_layer logical indicating if the map should update the bounds to only include this layer 邏輯指示地圖是否應(yīng)將邊界更新為僅包括此圖層
24 digits number of digits for rounding coordinates 舍入坐標(biāo)的位數(shù)
25 transitions list specifying the duration of transitions. 指定過渡持續(xù)時(shí)間的列表。
26 brush_radius radius of the brush in metres. Default NULL. If supplied, the arcs will only show if the origin or destination are within the radius of the mouse. If NULL, all arcs are displayed 畫筆的半徑(以米為單位)捶闸。默認(rèn)為NULL夜畴。如果提供了弧拖刃,則僅當(dāng)起點(diǎn)或終點(diǎn)在鼠標(biāo)的半徑內(nèi)時(shí)才會(huì)顯示弧。如果為NULL贪绘,則顯示所有弧