我试图用宣传单封装中的R画一个放大器和连接给出下表中的经度和纬度信息的标记.
| Observation | InitialLat | InitialLong | NewLat | NewLong |
|-------------|------------|-------------|-----------|-----------|
| A | 62.469722 | 6.187194 | 51.4749 | -0.221619 |
| B | 48.0975 | 16.3108 | 51.4882 | -0.302621 |
| C | 36.84 | -2.435278 | 50.861822 | -0.083278 |
| D | 50.834194 | 4.298361 | 54.9756 | -1.62179 |
| E | 50.834194 | 4.298361 | 54.9756 | -1.62179 |
| F | 50.834194 | 4.298361 | 51.4882 | -0.302621 |
| … 我想从一个特定的位置添加折线到其他许多闪亮 [R使用addPolylines的传单.但是,不是从一个位置链接到另一个位置,我只能按顺序将它们全部链接在一起.在板球车轮图中可以看到我想要实现的最好的例子:
.
observe({
long.path <- c(-73.993438700, (locations$Long[1:9]))
lat.path <- c(40.750545000, (locations$Lat[1:9]))
proxy <- leafletProxy("map", data = locations)
if (input$paths) {
proxy %>% addPolylines(lng = long.path, lat = lat.path, weight = 3, fillOpacity = 0.5,
layerId = ~locations, color = "red")
}
})
Run Code Online (Sandbox Code Playgroud)
它是一个反应式表达式,因为我希望它们被一个复选框激活.
我真的很感激任何帮助!
我的空格行为'list':
> SL1
[[1]]
class : SpatialLines
nfeatures : 1
extent : 253641, 268641, 2621722, 2621722 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=46 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
[[2]]
class : SpatialLines
nfeatures : 1
extent : 253641, 268641, 2622722, 2622722 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=46 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0
[[3]]
class : SpatialLines
nfeatures : 1
extent : 253641, 268641, 2623722, 2623722 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=46 +datum=WGS84 …Run Code Online (Sandbox Code Playgroud) 我的代码可以很好地生成从 A 点到 B 点的地图和线,但是对于远东半球的国家,该线会尝试穿过最短路径(例如澳大利亚以东)并中断以创建一条穿过该图的直线. 有什么建议?我缩短了代码并将其全部包含在下面以供使用。
提到(在代码中的链接中)使用greatCircle,但我无法让它工作。
谢谢!
adds <- c("Argentina",
"Australia",
"Germany",
"Japan",
"Korea")
# people are coming 'from' all those spots 'to' heidelberg
add0 <- "Salt Lake City, UT"
# get lat / lon
from <- geocode(adds)
to <- geocode(add0)
from
# see: http://flowingdata.com/2011/05/11/how-to-map-connections-with-great-circles/
library(maps)
library(geosphere)
# will need to adjust these limits...
xlim <- c(-170, 200)
ylim <- c(-50, 95)
quartz(file = "UCC.pdf",
type = "pdf",
height = 5, width = 9)
#print the map itself
map("world", …Run Code Online (Sandbox Code Playgroud) r ×4
leaflet ×2
dictionary ×1
geospatial ×1
list ×1
maps ×1
plot ×1
r-leaflet ×1
shiny ×1
spatial ×1