mardi 22 avril 2014

How do I select the subset of my lat/lon data that is highway travel using R?


Vote count:

0




I have some data which consists of time-stamped lat/lon pairs, a subset of which I've mapped out below using ggmap. If I wanted to select only the data consisting of travel along the highways, which you can kinda see on the map - the 280 running NW-SE between the green mountains and the grey flat are & the 101 cuts through the middle of the flat area where the red is dense - how would I select only that data?


A plot of some time stamped position data


What I'd ultimately like to achieve is a dataframe which contains only the highway/interstate travel. I've seen this question, which is a brief sketch of a possible solution in javascript, & suggests to use the Directions API to return the nearest road for any given point. I could then filter those results, but I'm wondering if anyone has found a cleaner solution.


Here's some sample data (CSV)


Here's the code to plot the above:



require(ggmap)
map<-get_googlemap(center="Palo Alto", zoom = 10)
ggmap(map) + geom_point(data = sample, aes(x = lon, y = lat),size = 3, color = "red")


You don't need an API key to run the above.



asked 29 secs ago






Aucun commentaire:

Enregistrer un commentaire