| kml-methods | R Documentation |
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.
## 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, ...)
obj |
object inheriting from the |
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) |
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.)
A KML file. By default parses the object name and adds a ".kml" extension.
Pierre Roudier, Tomislav Hengl and Dylan Beaudette
kml_open, kml_aes, kml_close, kml_compress
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.