Description Usage Arguments Details Value Author(s) See Also Examples
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.
1 2 3 4 5 6 7 8 9 10 | ## 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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # 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)
|
plotKML version 0.6-1 (2020-03-08)
URL: http://plotkml.r-forge.r-project.org/
Loading required package: sp
rgdal: version: 1.5-18, (SVN revision 1082)
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
Path to GDAL shared files: /usr/share/gdal
GDAL binary built with GEOS: TRUE
Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
Path to PROJ shared files: /usr/share/proj
Linking to sp version:1.4-4
To mute warnings of possible GDAL/OSR exportToProj4() degradation,
use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal.
Warning message:
In showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj = prefer_proj) :
Discarded datum Deutsches_Hauptdreiecksnetz in CRS definition
KML file opened for writing...
Reprojecting to +proj=longlat +datum=WGS84 +no_defs ...
Writing to KML...
Closing eberg-0.kml
Warning message:
In proj4string(obj) : CRS object has comment, which is lost in output
KML file opened for writing...
Reprojecting to +proj=longlat +datum=WGS84 +no_defs ...
Writing to KML...
Closing eberg-1.kml
Warning message:
In proj4string(obj) : CRS object has comment, which is lost in output
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.