Learn R Programming

plotKML (version 0.2-4)

kml-methods: 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

kml(obj, ...)

Arguments

obj
object inheriting from the Spatial* or the Raster* classes
...
additional aesthetics arguments (see details below)

Value

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

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

See Also

kml_open, kml_aes, kml_close, kml_compress

Examples

Run this code
# Plotting a SpatialPointsDataFrame object
data(eberg)
coordinates(eberg) <- ~X+Y
proj4string(eberg) <- CRS("+init=epsg:31467")
# Simple plot
kml(eberg, file = "eberg-0.kml")
# Plot using aesthetics
kml(eberg, colour = SNDMHT_A, size = CLYMHT_A, alpha = 0.75, file = "eberg-1.kml")
data(eberg_grid)
gridded(eberg_grid) <- ~x+y
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
# Plotting a SpatialPixelsDataFrame or a Raster* object
kml(eberg_grid, colour = DEMSRT6, file = "eberg_grid-0.kml")

Run the code above in your browser using DataLab