kmlPoints: Display locations in a KML document

Description Usage Arguments Value Author(s) See Also Examples

Description

This function displays the locations given in the data frame by longitude and latitude via KML.

Usage

 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())

Arguments

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 data.

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 createLookAt to specify the document's view point.

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 data.

...

additional arguments passed on to panel/

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 Placemark nodes. These are the strings displayed on the map.

description

a character vector giving a description string (typically HTML) for each Placemark elements being created, or an empty vector.

type

a string controlling whether to draw points, lines, both, etc. See plot.default.

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

Value

A KMLDoc object which is an internal C-level XML tree.

Author(s)

Duncan Temple Lang

See Also

kml kmlTime kmlPanel.points

Examples

 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")

duncantl/RKML documentation built on May 15, 2019, 5:31 p.m.