我剛剛發現這篇文章,並認爲這是一個有趣的問題。我想下載你的示例數據文件。不幸的是,該鏈接不再工作。因此,我無法嘗試我腦海中的整個過程。但是,如果您仍然嘗試完成此任務,我相信以下內容可以讓您繼續前進。
我最近注意到Natural Earth提供道路數據。也就是說,例如,您可以在美國的道路上行駛很長時間。如果您可以比較數據集中的lon/lat和道路數據的lon/lat,並確定數據點中的匹配項,則可以獲取所需的數據。我關心的是你的數據點的準確程度。如果lon/lat完美停留在你感興趣的道路上,那麼你會沒事的。但是如果有一些利潤率,你可能不得不考慮如何過濾你的數據。
我想在這裏留下的證據表明道路數據和googlemap匹配得很好。只要我看到輸出,道路數據就是可靠的。您可以使用道路數據對數據進行分類。這是我的代碼。
### Step 1: shapefile becomes SpatialLinesDataFrame.
foo <- readShapeLines("ne_10m_roads_north_america.shp")
### Step 2: If necessary, subset data before I use fortify().
### dplyr does not work with SpatialLinesDataFrame at this point.
CA <- foo %>%
subset(.,country == "United States" & state == "California")
### Step 3: I need to convert foo to data frame so that I can use the data
### with ggplot2.
ana <- fortify(CA)
### Step 4: Get a map using ggmap package
longitude <- c(-122.50, -121.85)
latitude <- c(37.15, 37.70)
map <- get_map(location = c(lon = mean(longitude), lat = mean(latitude)),
zoom = 12, source = "google",
maptype = "satellite")
ggmap(map) +
geom_path(aes(x = long, y = lat, group = group), data = ana)
這似乎是在公路上進行反向地址解析點經常給我附近的道路,所以通過反向地理編碼高速公路各點和過濾的策略將無法正常使用。 –
你可以做一個已知高速公路的白名單並使用它來過濾嗎?也許你收到了每個座標的多個條目? – Tyler