# Sun Apr 04 16:00:27 2021 -
# 字符編碼:UTF-8
# R 版本:R x64 4.0.5 for window 10
# cgh163email@163.com
# 個(gè)人筆記不負(fù)責(zé)任尝苇,拎了個(gè)梨??
.rs.restartR()
require(mapdeck)
rm(list = ls());gc()
?add_trips
# Sun Apr 04 23:17:48 2021 ----ex1--------------------------
set_token(my_mapbox_key)
sf <- city_trail
# [,1] [,2] [,3] [,4]
# [1,] 144.9998 -37.84512 21.8 1499569160
# [2,] 144.9998 -37.84508 21.8 1499569161
# [3,] 144.9998 -37.84502 21.4 1499569162
# [4,] 144.9999 -37.84501 21.2 1499569163
# [5,] 144.9999 -37.84493 20.9 1499569164
mapdeck(
location = c(145, -37.8)
, zoom = 10
, style = mapdeck_style("dark")
) %>%
add_trips(
data = sf
, animation_speed = 2000
, trail_length = 1000
# , stroke_colour = "#FFFFFF"
)
# Sun Apr 04 22:18:05 2021 --end
# Sun Apr 04 16:19:02 2021 ----手動(dòng)--------------------------
require(sf)
require(sfheaders)
?sfc_LINESTRING#創(chuàng)建簡(jiǎn)單要素幾何列表列
# 創(chuàng)建簡(jiǎn)單的要素幾何列表列,設(shè)置類埠胖,并添加坐標(biāo)參考系統(tǒng)和精度
# Sun Apr 04 17:42:01 2021 ----下載的軌跡制作--------------------------
#
map <- st_read('茶巖頂軌跡.geojson')
plot(map$geometry) # 預(yù)覽
map.xy <- map$geometry %>% st_coordinates() # 打散為普通矩陣剝除sf屬性
map.xy <- data.frame(
lon = map.xy[, 1],
lat = map.xy[, 2],
Z = map.xy[, 3]*2, # 高程
M = runif(dim(map.xy)[1], 1000, 5000) # 隨機(jī)數(shù)第四維
) # 重新構(gòu)建四維散點(diǎn)
# head(map.xy)
map.xyzm <- sf_linestring(map.xy) #轉(zhuǎn)為sf線條對(duì)象
str(map.xyzm);rm(map.xy)
# Sun Apr 04 17:05:35 2021 ------------------------------
mapdeck(
# location = c(113.3057 ,23.15426)
location = st_centroid(map$geometry)[[1]] # 位置中心點(diǎn)
, zoom =12
, style = mapdeck_style("light")
) %>%
add_trips(
data =map.xyzm
, animation_speed = 2000
, trail_length = 1000,
stroke_width = 8 #米
# start_time = 100,
# end_time = 100
# , stroke_colour = "#FFFFFF"
)
# Sun Apr 04 23:36:36 2021 --end
#隨機(jī)數(shù)模擬坐標(biāo)散點(diǎn):
map.sf <- data.frame(y= runif(100, 30, 80), #生成n個(gè)大于min糠溜,小于max的隨機(jī)數(shù) )
x = runif(100, 50,110),
1:100,
1:100
)
head(map.sf)
# Sun Jan 31 19:55:55 2021 --隨機(jī)數(shù)模擬完畢
map.sf.xyzm <- sf_linestring(map.sf) #轉(zhuǎn)為sf線條對(duì)象
plot(map.sf.xyzm |> st_zm())
# Sun Jul 11 16:46:48 2021 --
mapdeck(
location = c(60 ,33)
# location = st_centroid(map.sf)[[1]] # 位置中心點(diǎn)
, zoom =2
, style = mapdeck_style("light")
) %>%
add_trips(data = map.sf.xyzm
,end_time = 100 # 結(jié)束時(shí)間
,animation_speed = 20 # 刷新率
,trail_length = 50 # 拖影
,stroke_width = 8
)
空格分隔符表格
1 map a mapdeck map object 一個(gè)mapdeck地圖對(duì)象
2 data sf object with XYZM dimensions. 具有XYZM尺寸的sf對(duì)象。
3 stroke_colour variable of data or hex colour for the stroke. 筆畫的數(shù)據(jù)變量或十六進(jìn)制顏色直撤。
4 stroke_width width of the stroke in meters. Default 1. 筆畫的寬度(以米為單位)非竿。默認(rèn)值1。
5 opacity single value in [0,1] [0,1]中的單個(gè)值
6 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”)“
7 trail_length how long it takes for the trail to completely fade out (in same units as timestamps ) 足跡完全消失所需的時(shí)間(以時(shí)間戳為單位)
8 start_time the minimum timestamp 最小時(shí)間戳
9 end_time the maximum timestamp 最大時(shí)間戳
10 animation_speed speed of animation 動(dòng)畫速度
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的單個(gè)值。使用此值可以區(qū)分相同類型的形狀圖層众眨。具有相同ID的圖層可能會(huì)發(fā)生沖突并且無(wú)法正確繪制
12 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)在圖例中包括哪些顏色屬性娩梨。
13 legend_options A list of options for controlling the legend. 用于控制圖例的選項(xiàng)列表沿腰。
14 legend_format A list containing functions to apply to legend values. See section legend 包含要應(yīng)用于圖例值的函數(shù)的列表。參見圖例
15 digits number of digits for rounding coordinates 舍入坐標(biāo)的位數(shù)