r - 在 R 中使用 Open Street Map 和 get_osm {osmar}

标签 r openstreetmap osmar

我想附加一组相关的方式并给出一个地区的边界。 我尝试了以下但卡住了:

require(osmar)
require(XML)

# a set of open street map ways (lines) related as given by a relation..
# (if connected these ways represent the boundary of a political 
#  district in Tyrol/Austria)
myxml <- xmlParse("http://api.openstreetmap.org/api/0.6/relation/85647")

# extracting way ids at the according xml-nodes:
els <- getNodeSet(myxml, "//member[@ref]")
ways <- as.numeric(sapply(els, function(el) xmlGetAttr(el, "ref")))

# now I try to get one of those ways as an osmar-obj and plot it,
# which throws an error:
plot_ways(get_osm(way(ways[1])))

显然缺少一个边界框,但我不知道如何将它分配给这类对象。如果我解决了这个问题,我想用线/路制作一个多边形。

最佳答案

包的作者非常友好地提供了缺少当前文档的信息: 参数 get_osm(.., all = T) 只是丢失了...... all = T 所有相关元素都被检索。

要获得我想要的地区边界,请应用以下代码:

District_Boundary <- get_osm(relation(85647), all = T)

关于r - 在 R 中使用 Open Street Map 和 get_osm {osmar},我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8979946/

相关文章:

r - 如何在R中将NUM转换为INT?

java - 是否有可行的手写识别库/程序?

openstreetmap - overpass api - 请求任何有标签的节点

python - 如何使用 OSMNx/Networkx 添加边长度作为中间中心性的权重?

r - 如何解决打开 ".rattle"文件时出现的以下错误? "Error in .RGtkCall("S_gtk_file_chooser_dialog_new_with_backend

html - 使用操作按钮在 R Shiny 中发送电子邮件

android - 如何使用 Osmdroid 库在两个坐标之间绘制曲线

r - 在 R 中将具有多个线元素的 SpatialLinesDataframe 转换为 KML

r - 根据 gps 坐标列表更改基于开放街道 map 的 igraph 中路径边缘的权重