本文介绍了R:如何使用GPS识别道路类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有几个点的GPS坐标,我想知道他们是否在高速公路,干线道路或小路上,如果我能够识别道路名称,它会更大。我使用R小册子来绘制地图,并且我可以用OpenStreetMap看到不同类型的道路颜色不同,我不知道如何提取这些信息。如果它能解决我的问题,那么使用谷歌地图不是问题。 感谢您的帮助。 你可以从 ggmap 使用 revgeocode(): library(ggmap) gc revgeocode(gc) 其中: #[1]4333 Rue Sherbrooke O,Westmount,QC H3Z 1E2,Canada 注意:正如评论中所述,此方法使用Google Maps API,而不是OpenStreetMap。您每天有2500个查询的限制。您可以始终使用 geocodeQueryCheck() 来查看剩余的查询数量。 > 更新 如果您需要更详细的信息,请使用 output =所有并提取您需要的组件: lst g1 = c(-73.681069,41.433155), g2 = c(-73.643196,41.416240), g3 = c(-73.653324,41.464168)) res 其中给出: # $ g1 #$ g1 $ long_name #[1]Highway 52##$ g1 $ short_name #[1]NY-52 ##$ g1 $类型#[1]route###$ g2 #$ g2 $ long_name #[1]Carmel Avenue##$ g2 $ s hort_name #[1]US-6##$ g2 $ types #[1]route###$ g3 #$ g3 $ long_name #[1]Wakefield Road##$ g3 $ short_name #[1] Wakefield Rd##$ g3 $类型#[1]route I have a GPS coordinates of several points and I want to know if they are on a highway, or trunk road, or minor road, and it would be even greater if I could identify a road name. I'm using R leaflet to draw maps and I can see with OpenStreetMap that different types of roads are colored differently, and I wonder how I can extract this information. It's not a problem to use Google maps instead if it will solve my problem.I would appreciate any help. 解决方案 You can use revgeocode() from ggmap:library(ggmap)gc <- c(-73.596706, 45.485501)revgeocode(gc)Which gives:#[1] "4333 Rue Sherbrooke O, Westmount, QC H3Z 1E2, Canada"Note: As per mentioned in the comments, this method uses Google Maps API, not OpenStreetMap. You have a limit of 2500 queries per day. You can always check how many queries you have left using geocodeQueryCheck()From the package documentation:UpdateIf you need more detailed information, use output = "all" and extract the components you need:lst <- list( g1 = c(-73.681069, 41.433155), g2 = c(-73.643196, 41.416240), g3 = c(-73.653324, 41.464168))res <- lapply(lst, function(x) revgeocode(x, output = "all")[[1]][[1]][[1]][[2]])Which gives:#$g1#$g1$long_name#[1] "Highway 52"##$g1$short_name#[1] "NY-52"# #$g1$types#[1] "route"###$g2#$g2$long_name#[1] "Carmel Avenue"##$g2$short_name#[1] "US-6"##$g2$types#[1] "route"###$g3#$g3$long_name#[1] "Wakefield Road"##$g3$short_name#[1] "Wakefield Rd"##$g3$types#[1] "route" 这篇关于R:如何使用GPS识别道路类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-22 19:11