3

関連する一連のウェイを追加して、地区の境界を与えたいと思います。次のことを試しましたが、行き詰まりました:

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])))

どうやらバウンディングボックスがありませんが、この種のオブジェクトに割り当てる方法がわかりません..この問題が解決したら、ライン/ウェイから1つのポリゴンを作成したいと思います.

4

1 に答える 1

4

パッケージの作成者は親切にも、現在のドキュメントに欠けている情報を提供してくれました: 引数 get_osm(.., all = T) が単純に欠落していました... all = T を使用すると、関連するすべての要素が取得されます。

目的の地区境界を取得するには、次のコードが適用されます。

District_Boundary <- get_osm(relation(85647), all = T)
于 2012-01-26T09:24:56.743 に答える