[R-sig-Geo] writeOGR with 2+ layers in 1 KML file

David Holstius david.holstius at berkeley.edu
Tue Apr 5 22:14:03 CEST 2011


Hi, I would like to write two different Spatial* objects, as two different layers, to the same KML file using rgdal::writeOGR(). 

If I do something like:

  > writeOGR(bar, driver="KML", dsn="foo.kml", layer="bar")

... I get a KML Document with a Folder element inside named "bar". So far, so good. 

But if I follow that with:

  > writeOGR(baz, driver="KML", dsn="foo.kml", layer="baz")

... the contents of foo.kml are obliterated and replaced with new contents. I would prefer that another Folder, named "baz", be created in "foo.kml" without erasing any other Folder elements.

Is this possible? Is there a flag I didn't find? Am I doing it wrong? Many thanks in advance,

Very best,
David

--
David Holstius
PhD Student in Environmental Health Sciences
UC Berkeley School of Public Health



More information about the R-sig-Geo mailing list