跟前面的差不多饶氏。
# Wed Sep 02 21:15:48 2020 -
# 字符編碼:UTF-8
# R 版本:R x64 4.0.2 for window 10
# cgh163email@163.com
# 個(gè)人筆記不負(fù)責(zé)任
# —— 拎了個(gè)梨??
# Add Scatterplot 圓餅散點(diǎn)圖
#
rm(list=ls());gc()
.rs.restartR()
require(mapdeck)
# key <- 'abc'
set_token( key )
# Wed Sep 02 22:04:39 2020 ---基礎(chǔ)作圖---------------------------
mapdeck( style = mapdeck_style("dark"), pitch = 45 ) %>%
add_scatterplot(
data = capitals
, lat = "lat"
, lon = "lon"
, radius = 100000
# , fill_colour = "country"
, layer_id = "scatter_layer"
, tooltip = "capital"
)
# Wed Sep 02 22:04:32 2020 --使用圖例選項(xiàng)----------------------------
mapdeck( style = mapdeck_style("dark"), pitch = 45 ) %>%
add_scatterplot(
data = capitals
, lat = "lat"
, lon = "lon"
, radius = 100000
, fill_colour = "lon"
, stroke_colour = "lat"
, layer_id = "scatter_layer"
, tooltip = "capital"
, legend = T
, legend_options = list( digits = 5 )
)
# Wed Sep 02 22:04:13 2020 --經(jīng)度做漸變填充色----------------------------
# 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), ] # 清除缺失項(xiàng)
mapdeck(style = mapdeck_style("dark"), pitch = 45 ) %>%
add_scatterplot(
data = df
, lat = "lat"
, lon = "lng"
, layer_id = "scatter_layer"
, stroke_colour = "lng" # 填色參數(shù)
)
# Wed Sep 02 22:04:55 2020 -sf對(duì)象應(yīng)用-----------------------------
library(sfheaders)
sf <- sfheaders::sf_point( df, x = "lng", y = "lat")
mapdeck( style = mapdeck_style("dark"), pitch = 45 ) %>%
add_scatterplot(
data = sf
, radius = 100
# ,stroke_colour = 'country'
# , fill_colour = "country"
, layer_id = "scatter_layer"
, tooltip = "capital"
)
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 lon column containing longitude values 包含經(jīng)度值的列
4 lat column containing latitude values 包含緯度值的列
5 polyline optional column of data containing the polylines, if using encoded polylines 如果使用編碼折線,則包含折線的數(shù)據(jù)的可選列
6 radius in metres. Default 1 以米為單位疹启。默認(rèn)值1
7 radius_min_pixels the minimum radius in pixels. Can prevent circle from getting too small when zoomed out small for the given zoom level 最小半徑(以像素為單位)古程。對(duì)于給定的縮放級(jí)別,縮小時(shí)可以防止圓變得太小
8 radius_max_pixels the maximum radius in pixels. Can prevent the circle from getting too big when zoomed in 最大半徑(以像素為單位)喊崖≌跄ィ可以防止放大時(shí)圓圈變得太大
9 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)制顏色荤懂,請(qǐng)?jiān)跀?shù)據(jù)上使用單個(gè)值或一列十六進(jìn)制顏色
10 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
11 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)制顏色,請(qǐng)?jiān)跀?shù)據(jù)上使用單個(gè)值或一列十六進(jìn)制顏色
12 stroke_width width of the stroke in meters. If used, elevation is ignored. Default 1. 筆畫的寬度(以米為單位)册烈。如果使用戈泼,則忽略高程婿禽。默認(rèn)值1。
13 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
14 tooltip variable of data containing text or HTML to render as a tooltip 包含文本或HTML的數(shù)據(jù)變量以呈現(xiàn)為工具提示
15 auto_highlight logical indicating if the shape under the mouse should auto-highlight 邏輯指示鼠標(biāo)下方的形狀是否應(yīng)自動(dòng)突出顯示
16 highlight_colour hex string colour to use for highlighting. Must contain the alpha component. 用于突出顯示的十六進(jìn)制字符串顏色模聋。必須包含alpha分量。
17 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ā)生沖突并且無(wú)法正確繪制
18 id an id value in data to identify layers when interacting in Shiny apps. 數(shù)據(jù)中的ID值,以在“閃亮”應(yīng)用程序中進(jìn)行交互時(shí)識(shí)別圖層灶搜。
19 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”)“
20 na_colour hex string colour to use for NA values 用于NA值的十六進(jìn)制字符串顏色
21 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)在圖例中包括哪些顏色屬性攻人。
22 legend_options A list of options for controlling the legend. 用于控制圖例的選項(xiàng)列表取试。
23 legend_format A list containing functions to apply to legend values. See section legend 包含要應(yīng)用于圖例值的函數(shù)的列表。參見圖例
24 digits number of digits for rounding coordinates 舍入坐標(biāo)的位數(shù)
25 update_view logical indicating if the map should update the bounds to include this layer 邏輯指示地圖是否應(yīng)更新邊界以包括此圖層
26 focus_layer logical indicating if the map should update the bounds to only include this layer 邏輯指示地圖是否應(yīng)將邊界更新為僅包括此圖層
27 transitions list specifying the duration of transitions. 指定過(guò)渡持續(xù)時(shí)間的列表怀吻。
28 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,則顯示所有弧```