kml-methods {plotKML}R Documentation

Write to a KML file

Description

Writes any Spatial* object (from the sp package) or Raster* object (from the raster package) to a KML file via the plotKML.fileIO environment. Various aesthetics parameters can be set via colour, alpha, size, shape arguments. Their availability depends on the class of the object to plot.

Usage

## S4 method for signature 'Raster'
kml(obj, folder.name, file.name, kmz, ...)
## S4 method for signature 'Spatial'
kml(obj, folder.name, file.name, kmz, ...)
## S4 method for signature 'STIDF'
kml(obj, folder.name, file.name, kmz, ...)
## S4 method for signature 'SoilProfileCollection'
kml(obj, folder.name, file.name, kmz, ...)
## S4 method for signature 'SpatialPhotoOverlay'
kml(obj, folder.name, file.name, kmz, ...)

Arguments

obj

object inheriting from the Spatial* or the Raster* classes

folder.name

character; folder name in the KML file

file.name

character; output KML file name

kmz

logical; specief whether to compress the KML file

...

additional aesthetics arguments (see details below)

Details

To kml you can also pass folder.name, file.name (output file name *.kml), overwrite (logical; overwrites the existing file) and kmz (logical; specifies whether to compress the kml file) arguments. Gridded objects (objects of class "SpatialGridDataFrame" or "RasterLayer" require at least one aesthetics parameter to run, usually the colour.)

Value

A KML file. By default parses the object name and adds a ".kml" extension.

Author(s)

Pierre Roudier, Tomislav Hengl and Dylan Beaudette

See Also

kml_open, kml_aes, kml_close, kml_compress

Examples

# Plotting a SpatialPointsDataFrame object
library(rgdal)
data(eberg)
eberg <- eberg[runif(nrow(eberg))<.1,]
library(sp)
library(rgdal)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
## Not run: # Simple plot
kml(eberg, file = "eberg-0.kml")
# Plot using aesthetics
shape = "http://maps.google.com/mapfiles/kml/pal2/icon18.png"
kml(eberg, colour = SNDMHT_A, size = CLYMHT_A, 
   alpha = 0.75, file = "eberg-1.kml", shape=shape)

## End(Not run)

[Package plotKML version 0.5-9 Index]