Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Curved Flight path using R's Leaflet Package

Tags:

r

leaflet

Currently I'm able to draw a straight line between countries using the following code:

library(leaflet) 
leaflet() %>% addTiles() %>% addPolylines(lat=c(38.8833, 35.00), lng=c(-77.0167, 103.00))

enter image description here

What I'm trying to produce is a more realistic flight path, where the straight line is actually curved. Similar to this:

Curved Path Example

For the sake of this question, I'd like to tailor the answer within the Leaflet package. Any help would be much appreciated.

like image 994
Steven_ Avatar asked Dec 28 '15 19:12

Steven_


1 Answers

following up on mrub, just pass the object you get from gcIntermediate to leaflet. something like this:

library(leaflet)
library(geosphere)
gcIntermediate(c(5,52), c(-120,37),
               n=100, 
               addStartEnd=TRUE,
               sp=TRUE) %>% 
leaflet() %>% 
addTiles() %>% 
addPolylines()

enter image description here

like image 108
einar Avatar answered Oct 12 '22 23:10

einar