我刚刚发现这篇文章,并认为这是一个有趣的问题。我想下载你的示例数据文件。不幸的是,该链接不再工作。因此,我无法尝试我脑海中的整个过程。但是,如果您仍然尝试完成此任务,我相信以下内容可以让您继续前进。
我最近注意到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