kmlTime: Create a KML animation

Description Usage Arguments Value Author(s) See Also Examples

Description

This is the lower-level version that one can call directly or indirectly via the generic kml formula which understands an extended formula language.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
kmlTime(data, times = data$time, style = character(), lty = character(), 
        docName = deparse(substitute(data)), docDescription = NA,
        folderName = deparse(substitute(data)),
        window = c(longitude = mean(.longitude, na.rm = TRUE),
                   latitude = mean(.latitude, na.rm = TRUE),
                    altitude = 4100000, tilt = 0, heading = 0),
        docStyles = list(), groups = character(), panel = kmlPanel.default, ...,
         kml.doc = createKMLDoc(docName, docDescription, window, data),
        .longitude = data$long, .latitude = data$lat,
        ids = if (length(names(.longitude)))
                names(.longitude)
              else
                rownames(data))

Arguments

data

a data frame

times

the time variable as a vector. If this is has a names attribute, these names are used to label the points.

style

a vector of style names controlling the appearance (color, image, etc.) of the points on the KML display. This should have as many elements as there are time points in the data set

lty

a vector of style names controlling the appearance of the lines connecting the points on the KML display. This should have as many elements as there are time points in the data set

docName

the name of the document (not the file) used within the KML meta-data. If this is not specified, this is taken from the "name" of the data, i.e. the expression for the first argument.

docDescription

a character string giving a human-readable description of the KML document. This is added to the KML meta-data and displayed to the viewer in Google Earth.

folderName

the name of the folder within the KML document

window

a named vector specifying values for the KML LookAt element. This includes latitude and longitude, altitude, heading, tilt, range and altitudeMode. latitude and longitude are computed from the mean of the corresponding elements in the data frame. (Currently, the names of the variables representing these variables are hard coded.)

docStyles

a list KML style nodes (as XML internal nodes) or a list of objects which define the contents of a KML style. See makeStyle.

groups

a vector that is used to group the observations in the dataset into sub-groups, much like within a panel in lattice, so that the sub-group can be displayed as a unit. The purpose of this is to group the graphical elements displayed in KML in separate folders, one for each level of the group factor.

panel

the function that is used to generate the KML content for each of the sub-groups or the entire data as a single unit if there are no groups specified.

...

additional arguments that are passed directly to the panel function in each call.

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.

Value

An XML/KML document, returned invisibly so it does not print on the console.

Author(s)

Duncan Temple Lang

See Also

kml

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
styles = list("ball_green" =
                 list("IconStyle" = list("scale" = "0.5",
                                         "Icon" = c("href" = system.file("Icons", "greendot.png", package = "RKML"))),
                                         "BalloonStyle" = "$[description]"),
              "ball_red" =
                 list("IconStyle" = list("scale" = "0.5",
                                         "Icon" = c("href" = system.file("Icons", "reddot.png", package = "RKML"))),
                                         "BalloonStyle" = "$[description]"),
              "line_green" = list(LineStyle = list(color = I("ff8adfb2"), width = 4)),
              "line_red" = list(LineStyle = list(color = I("ff999afb"), width = 2)))

data(elephantSeal)
outDays = 44
direction = factor(c(rep("Out", outDays),
                     rep("Return", nrow(elephantSeal) - outDays)))
   
docDescription =  "Elephant seal data <a href='http://www.stat.berkeley.edu/~brill'>Stewart & Brillinger</a>"

o = kmlTime(elephantSeal, times = elephantSeal$date, 
            name = format(elephantSeal$date, "%d-%m"),
            docName = "Elephant Seal Travel Path",
            docDescription = docDescription,
            style = c("ball_green", "ball_red")[direction], 
            lty = c("line_green", "line_red"), 
            docStyles = styles, addLines = TRUE)

saveXML(o, "elephantSeal.kml")


o = kmlTime(elephantSeal, time = elephantSeal$date, 
            name = format(elephantSeal$date, "%d-%m"),
            style = c("ball_green", "ball_red")[direction], 
            lty = c("line_green", "line_red")[direction],
            docName = "Elephant Seal Travel Path",
            docDescription = docDescription,
            groups = gl(2, nrow(elephantSeal)),
            docStyles = styles, addLines = TRUE)

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