I try to convert a spatial object (a river retrieved from OSM) with multiple lines to KML. For an object with a single line it is easy with kmlLine. However, with multiple lines the below approach is not working and my attempts to adapt the example from the documentation were in vain:
# 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")