Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

kmlPoints

Create and write a KML file on the basis of a given Points object


Description

The function is used to create and write a KML file on the basis of a given SpatialPointsDataFrame object for the usage in Google Earth resp. Google Maps.

Usage

kmlPoints(obj=NULL, kmlfile=NULL, kmlname="", kmldescription="",
    name=NULL, description="",
    icon="http://www.gstatic.com/mapspro/images/stock/962-wht-diamond-blank.png")

Arguments

obj

a SpatialPointsDataFrame object

kmlfile

if not NULL the name as character string of the kml file to be written

kmlname

the name of the KML layer

kmldescription

the description of the KML layer (HTML tags allowed)

name

a character vector to be used as names for each KML Placemark

description

a character vector to be used as the description for each KML Placemark (HTML tags allowed)

icon

a character vector of icon URLs to be used in the style associated with each KML Placemark

Details

The function is used to convert a given SpatialPointsDataFrame object into a series of KML Placemarks, each with a single Point. If kmlfile is not NULL the result will be written into that file. If kmlfile is NULL the generated KML lines will be returned (see also value).

If name=NULL, the <name> tag for each Placemark will be 'site #'. If a single value is used for name or description, that value will be replicated for each Placemark. If a single value is used for icon, only a single style will be created and that style will be referenced by each Placemark.

Note that the geometries should be in geographical coordinates with datum WGS84.

Value

x is a list with the elements style and content containing the generated lines of the KML file as character vectors if kmlfile is NULL.

y is a list with the elements header and footer representing the KML file' header resp. footer if obj is NULL.

KML icons

Author(s)

Jonathan Callahan

See Also

Examples

data(SplashDams)
num <- length(SplashDams)
td <- tempdir()
kmlfile <- paste(td, "OregonSplashDams.kml", sep="/")
kmlname <- "Oregon Splash Dams"
kmldescription <- paste("Data for Splash Dams in western Oregon.",
 "See http://www.fs.fed.us/pnw/lwm/aem/people/burnett.html#projects_activities",
 "for more information.")
icon <- "http://www.gstatic.com/mapspro/images/stock/962-wht-diamond-blank.png"
name <- paste("Dam on",SplashDams$streamName)
description <- paste("<b>owner:</b>", SplashDams$owner, "<br><b>dates:</b>", SplashDams$datesUsed)

kmlPoints(SplashDams, kmlfile=kmlfile, name=name, description=description,
          icon=icon, kmlname=kmlname, kmldescription=kmldescription)

maptools

Tools for Handling Spatial Objects

v1.1-1
GPL (>= 2)
Authors
Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>), Nicholas Lewin-Koh [aut], Edzer Pebesma [ctb], Eric Archer [ctb], Adrian Baddeley [ctb], Nick Bearman [ctb], Hans-Jörg Bibiko [ctb], Steven Brey [ctb], Jonathan Callahan [ctb], German Carrillo [ctb], Stéphane Dray [ctb], David Forrest [ctb], Michael Friendly [ctb], Patrick Giraudoux [ctb], Duncan Golicher [ctb], Virgilio Gómez Rubio [ctb], Patrick Hausmann [ctb], Karl Ove Hufthammer [ctb], Thomas Jagger [ctb], Kent Johnson [ctb], Matthew Lewis [ctb] (<https://orcid.org/0000-0003-2244-4078>), Sebastian Luque [ctb], Don MacQueen [ctb], Andrew Niccolai [ctb], Edzer Pebesma [ctb], Oscar Perpiñán Lamigueiro [ctb], Ethan Plunkett [ctb], Ege Rubak [ctb] (<https://orcid.org/0000-0002-6675-533X>), Tom Short [ctb], Greg Snow [ctb], Ben Stabler [ctb], Murray Stokely [ctb], Rolf Turner [ctb]
Initial release
2021-03-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.