2012-01-23 40 views
2

我想添加一组相关的并给出分区边界的方法。 我尝试以下,但卡住了起来:在R中使用get_osm中的开放式街道地图{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]))) 

显然有一个外接矩形框的失踪,但我不知道如何把它分配给这种对象。如果我得到这个问题解决了,我想从线条/方式中制作一个多边形。

回答

2

该软件包的作者是如此友好,以提供缺少当前文档的信息: get_osm(..,all = T)的参数完全缺失...... all = T检索所有相关元素。

,以获得我的期望区边界下面的代码适用于:

District_Boundary <- get_osm(relation(85647), all = T) 
相关问题