Description Usage Arguments Value Author(s) See Also Examples
This function displays the locations given in the data frame by longitude and latitude via KML.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | kmlPoints(data = NULL, style = character(),
docName = if(missing(data)) deparse(substitute(.longitude)) else deparse(substitute(data)),
docDescription = NA,
folderName = if(missing(data)) docName else deparse(substitute(data)),
window = c(longitude = mean(.longitude, na.rm = TRUE),
latitude = mean(.latitude, na.rm = TRUE),
altitude = 4100000, tilt = 0, heading = 0),
docStyles = I(""), panel = kmlPanel.points,
type = "p", groups = character(),
..., panelVar = NULL,
kml.doc = createKMLDoc(docName, docDescription, window, data),
.longitude = data$long,
.latitude = data$lat,
ids = if(length(names(.longitude)))
names(.longitude)
else
rownames(data),
.names = if ("name" %in% names(data))
data$name
else
rownames(data),
description = character(), col = character(), lty = character())
|
data |
the data frame containing variables longitude and latitude, at least, and also optionally description, name, id, styleUrl |
col |
a character vector giving the styleUrl names to use. This should have as many rows as |
docName |
a string giving the name of the document to appear in the Places panel in Google Earth. |
docDescription |
a string, potentially containing HTML, that describes the document |
folderName |
the name of the folder within this document for all the points. If this is NA, we don't create a folder but add the Placemark elements directly under the document. There are advantages and disadvantages to this. |
window |
a vector that is passed to |
docStyles |
a list of style definitions. These are added to the document and can be used by the Placemark nodes to control the appearance |
panel |
the function that actually creates the Placemark nodes for the observations in |
... |
additional arguments passed on to |
kml.doc |
the KML document. This can be specified by the caller if it is already created. |
.longitude |
the numeric vector specifying the longitude values |
.latitude |
the numeric vector specifying the latitude values |
ids |
vector giving the identifiers/labels for each of the observations. |
.names |
the names to use for identifying the |
description |
a character vector giving a description string
(typically HTML) for each |
type |
a string controlling whether to draw points, lines, both, etc.
See |
panelVar |
the variable used to group the observation into separate folders. This can be thought of as analogous to the conditioning variable in a lattice plot. |
groups |
an empty vector or a vector treated as a factor that is used to split the data into sub-groups within a panel/folder. |
style |
a vector of style identifiers to use for the individual placemark elements. |
lty |
the line type which is converted to a style |
A KMLDoc object which is an internal C-level XML tree.
Duncan Temple Lang
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | data(USCities, package = "RKML")
USCities$longitude = - USCities$longitude
dd = kmlPoints(USCities, docName = "US Cities", folderName = NA, description = paste(USCities$name, USCities$state, sep = ", "))
saveXML(dd, "cities.kml")
# This shows using the formula notation to specify which variables are which.
myData = USCities
names(myData)[1:2] = c("Y", "X")
dd = kml(~ X + Y, myData, "Cities")
saveXML(dd, "myCities.kml")
# use styles to display an additional attribute, e.g. average income, population, etc.
#
caCities = subset(USCities, name %in% c("Sacramento", "SanFrancisco", "LosAngeles"))[c(1, 2, 4),]
doc = kmlPoints(caCities, addLines = TRUE)
saveXML(doc, "lines.kml")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.