目前,我可以使用以下代码在国家/地区之间绘制直线:
library(leaflet)
leaflet() %>% addTiles() %>% addPolylines(lat=c(38.8833, 35.00), lng=c(-77.0167, 103.00))
Run Code Online (Sandbox Code Playgroud)
我想要产生的是更真实的飞行路径,其中直线实际上是弯曲的.与此类似:
为了这个问题,我想在Leaflet包中定制答案.任何帮助将非常感激.
我正在尝试在地图上创建Leaflet纬度/经度点之间的线。这是一个示例输入数据:
segment_id latitude1 longitude1 latitude2 longitude2 len
1 1 48.15387 17.07388 48.15396 17.07387 10.98065
2 1 48.15396 17.07387 48.15404 17.07377 11.31327
3 1 48.15404 17.07377 48.15410 17.07364 11.74550
4 1 48.15410 17.07364 48.15412 17.07349 11.48138
5 1 48.15412 17.07349 48.15412 17.07334 11.63625
6 2 48.15424 17.07307 48.15432 17.07299 10.79304
Run Code Online (Sandbox Code Playgroud)
结果应该是 6 行lat1,lng1-> lat2,lng2。我很难使用addPolylines,它会产生额外的不需要的线条,我不知道为什么。
这就是它应该的样子,没有多余的线堆叠在一起:D
到目前为止,这是我的代码,但它是垃圾:
drawEdges <- function(x) {
d <- cbind(x$latitude1,x$latitude2)
s <- rep(1:nrow(x), each = 2) + (0:1) * nrow(x)
latitudeOut …Run Code Online (Sandbox Code Playgroud) 我正在使用 R 编程语言。
使用“leaflet”库,我为这 5 个城市制作了以下地图:
library(dplyr)
library(leaflet)
map_data <- data.frame("Lat" = c(43.6426, 43.6424, 43.6544, 43.6452, 43.6629), "Long" = c(-79.3871, -79.3860, -79.3807, -79.3806,-79.3957 ), type = c(1,2,3,4,5))
map_data$type = as.factor(map_data$type)
leaflet(map_data) %>%
addTiles() %>% addCircleMarkers(stroke = FALSE, label = ~type,fillOpacity = 0.8, labelOptions = labelOptions(direction = "center",style = list('color' = "white"),noHide = TRUE, offset=c(0,0), fill = TRUE, opacity = 1, weight = 10, textOnly = TRUE))
Run Code Online (Sandbox Code Playgroud)
在我创建的上面的地图上,我现在想根据它们的“数字”“连接”地图上(在路线中)的所有这些“点”(即城市)(例如,将 1 与 2、2 与 3 连接) , 3 与 4, 4 与 …
我正在尝试绘制流程图(适用于新加坡).我有Entry(Lat,Long)和Exit(Lat,long).我试图在新加坡地图中映射从入口到出口的流量.
structure(list(token_id = c(1.12374e+19, 1.12374e+19, 1.81313e+19,
1.85075e+19, 1.30752e+19, 1.30752e+19, 1.32828e+19, 1.70088e+19,
1.70088e+19, 1.70088e+19, 1.05536e+19, 1.44818e+19, 1.44736e+19,
1.44736e+19, 1.44736e+19, 1.44736e+19, 1.89909e+19, 1.15795e+19,
1.15795e+19, 1.15795e+19, 1.70234e+19, 1.70234e+19, 1.44062e+19,
1.21512e+19, 1.21512e+19, 1.95909e+19, 1.95909e+19, 1.50179e+19,
1.50179e+19, 1.24174e+19, 1.36445e+19, 1.98549e+19, 1.92068e+19,
1.18468e+19, 1.18468e+19, 1.92409e+19, 1.92409e+19, 1.21387e+19,
1.9162e+19, 1.9162e+19, 1.40385e+19, 1.40385e+19, 1.32996e+19,
1.32996e+19, 1.69103e+19, 1.69103e+19, 1.57387e+19, 1.40552e+19,
1.40552e+19, 1.00302e+19), Entry_Station_Lat = c(1.31509, 1.33261,
1.28425, 1.31812, 1.33858, 1.29287, 1.39692, 1.37773, 1.33858,
1.33322, 1.28179, 1.30036, 1.43697, 1.39752, 1.27637, 1.39752,
1.41747, 1.35733, 1.28405, 1.37773, 1.35898, 1.42948, 1.32774,
1.42948, 1.349, …Run Code Online (Sandbox Code Playgroud)