Learn R Programming

plotKML (version 0.2-4)

kml_layer.Raster: Writes raster objects to KML

Description

Writes rasters to PNG images and makes a KML code (ground overlays). Works with "RasterLayer" and "RasterStack" class objects. Target attributes can be specified using aesthetics arguments (e.g. "colour").

Usage

kml_layer.Raster(obj, plot.legend = TRUE, metadata = NULL, raster_name, ...)

Arguments

obj
object of class "RasterLayer", "SpatialPixelsDataFrame" or "SpatialGridDataFrame"
plot.legend
logical; specify whether a map legend should be generated automatically
metadata
(optional) specify the metadata object
raster_name
(optional) specify the output file name (PNG)
...
additional aesthetics arguments

Details

Google Earth does not properly handle a 24-bit PNG file which has a single transparent color (read more at http://groups.google.com/group/earth-help/{Google Earth Help}). To force transparency, plotKML will try to set it using the -matte -transparent "#FFFFFF" option in the http://www.imagemagick.org/Usage/masking/{ImageMagick convert program} (ImageMagick needs to be installed separately and located using plotKML.env()).

See Also

kml-methods, kml_open, kml_layer.RasterBrick

Examples

Run this code
data(eberg_grid)
coordinates(eberg_grid) <- ~x+y
gridded(eberg_grid) <- TRUE
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
data(SAGA_pal)
r <- raster(eberg_grid["TWISRT6"])
# KML plot with a single raster:
kml(r, colour_scale = SAGA_pal[[1]], colour = TWISRT6)

Run the code above in your browser using DataLab