複数の行がある空間オブジェクト(OSMから取得した川)をKMLに変換しようとしています。単一行のオブジェクトの場合、kmlLineを使用すると簡単です。ただし、複数行の場合、以下のアプローチは機能せず、ドキュメントからの例を適応させる試みは無駄でした。
# get OSM data:
library(osmar)
library(maptools)
salzach <- get_osm(relation(408582), full = T)
sp_salzach <- as_sp(salzach, what = "lines")
# convert to KML:
kmlLine(sp_salzach, "salzach.kml", lwd = 3, col = "blue", name = "Salzach")
Warning:
In kmlLine(sp_salzach, "salzach.kml", lwd = 3, col = "blue", name = "Salzach") :
Only the first Lines object with the ID '23633534' is taken from 'obj'
# shell.exec("salzach.kml")