简体   繁体   中英

Plotting GPS coordinates in ggmap

I have one problem. When I plot my coordinates using ggmap it does not connect segments according to date column. I end up having a weird map. Any idea how to fix this? Thanks for your help in advance.

this is what did.

p=ggmap(mapImageData)+
  geom_point(aes(x = Longitude, y = Latitude, group=DataID, color=factor(DataID)), 
            size = 4,
            pch= 20,
            data=koeco)
p + geom_line(aes(x = Longitude, y = Latitude, group=DataID, color=factor(DataID)),
            size = 1,
            data=koeco) +
  theme_bw() +
  annotate("text", x=110.3539, y=48.8, label = "Start", 
                       colour = I("red"), size = 5) +
  annotate("text", x=116.2648, y=28.5, label = "End",
           colour = I("red"), size = 5) +
  labs(x = "Longitude", y = "Latitude", colour = "Routes")

起重机运动

The help for geom_line says:

Description:

     Connect observations, ordered by x value.

The help for geom_path says:

Description:

     Connect observations in original order

So I'm guessing you should use geom_path . Its a guess because you haven't given us some data to try this on.

By "original order" it means the order in the data frame. If your data isn't in date-sorted order then it will still jump around, but I'm guessing (also) that your data frame is sorted by date (these things usually are).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM