kml_layer.SpatialPixels {plotKML}R Documentation

Writes SpatialPixels or SpatialGrid objects to KML

Description

Writes sp classes "SpatialGrid" or "SpatialPixels" to PNG images and makes a KML document (ground overlays). Target attributes can be specified using aesthetics arguments (e.g. "colour").

Usage

kml_layer.SpatialPixels(obj, subfolder.name = paste(class(obj)), raster_name, 
     plot.legend = TRUE, metadata = NULL, 
     png.width = gridparameters(obj)[1,"cells.dim"], 
     png.height = gridparameters(obj)[2,"cells.dim"], 
     min.png.width = 800, TimeSpan.begin, TimeSpan.end,
     layer.name, png.type = "cairo-png", ...)

Arguments

obj

object of class "RasterLayer", "SpatialPixelsDataFrame" or "SpatialGridDataFrame"

subfolder.name

character; optional subfolder name

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)

png.width

(optional) width of the PNG file

png.height

(optional) height of the PNG file

min.png.width

(optional) minimum width of the PNG file

TimeSpan.begin

object of class "POSIXct"; (optional) begin of the sampling period

TimeSpan.end

object of class "POSIXct"; (optional) end of the sampling period

layer.name

character; optional layer name

png.type

character; PNG type

...

additional aesthetics arguments

Details

Google Earth does not properly handle a 24-bit PNG file which has a single transparent color (read more at Google Earth Help). To force transparency, plotKML will try to set it using the -matte -transparent "\#FFFFFF" option in the ImageMagick convert program (ImageMagick needs to be installed separately and located using plotKML.env()). The PNG export uses the 'cairographics', which will never use a palette and normally creates a larger 32-bit ARGB file, but then always allows transparancy. On some Unix run machines the png.type argument has to be set manually to avoid producing empty PNGs.

Author(s)

Tomislav Hengl, Pierre Roudier and Dylan Beaudette

See Also

kml-methods, kml_open, kml_layer.Raster, plotKML-method

Examples

data(eberg_grid)
library(sp)
library(rgdal)
library(raster)
coordinates(eberg_grid) <- ~x+y
gridded(eberg_grid) <- TRUE
proj4string(eberg_grid) <- CRS("+init=epsg:31467")
data(SAGA_pal)
## Not run: ## KML plot with a single raster:
kml(eberg_grid, colour_scale = SAGA_pal[[1]], colour = TWISRT6)
## make a larger image:
kml(eberg_grid, colour_scale = SAGA_pal[[1]], colour = TWISRT6, 
  png.width = 600, png.height = 600)

## End(Not run)

[Package plotKML version 0.5-8 Index]