1

I am drawing some flight tracks on an interactive map via tmap package. And I want to create 5 nautical mile buffet around the flight track at the same time.

But when those points located around the 180° meridian, the line would be linked via different orientation.

The map outcome sample is here

How can I relocate the interactive map to the suitable center and avoid wrong linking of the track?

I have flight data flying toward the west and also some are toward the east. Now the flight which heading West is plotted correctly as below.

The map outcome sample 2

I want R could always plot the map with the correct center.

The sample data CSV is here

data sample on google drive

And my code is as below

library(tmap)
library(rgeos)
library(sp)
temp<-read.csv("demo1.csv")

sp.data <- SpatialPointsDataFrame(temp[,c("LONGITUDE","LATITUDE")],temp,proj4string=CRS("+init=epsg:4326"))  

tmap_mode("view")
ls1 <- Lines(Line(temp[,c("LONGITUDE","LATITUDE")]),ID=as.character("demo1"))  
OFPtrack <- SpatialLines(list(ls1),proj4string=CRS("+init=epsg:4326"))
OFPtrack.moll <- sp::spTransform(OFPtrack, CRSobj = "+proj=moll")
  #create buffer polygon
  line_buffers <- rgeos::gBuffer(OFPtrack.moll,width=9260,byid=T) 
#9260meters=5 Nautical Miles  
  m <- tm_shape(OFPtrack)+tm_lines()+
   tm_shape(line_buffers)+tm_borders(alpha=0.4)+tm_fill(col="grey",alpha=0.4)+
   tm_shape(sp.data)+tm_dots(col="grey",border.lwd=0.1)
Zoe
  • 27,060
  • 21
  • 118
  • 148
Ivan Lin
  • 33
  • 4

0 Answers0