kml_layer.STIDF {plotKML}R Documentation

Write irregular spatio-temporal observations (points, lines and polygons) to KML

Description

Writes an object of class "STIDF" (unstructured/irregular spatio-temporal data) to a KML file with a possibility to parse attribute variables using several aesthetics arguments.

Usage

kml_layer.STIDF(obj, dtime, ...)

Arguments

obj

space-time object of class "STIDF" (spatio-temporal irregular data frame) or class "STFDF" (spatio-temporal full data frame)

dtime

temporal support (point or block) expressed in seconds

...

additional arguments that can be passed to the kml_layer.Spatial method

Details

An object of class "STIDF" contains a slot of type "Spatial*", which is parsed via the kml_layer method depending on the type of spatial object (points, lines, polygons). The dateTime is defined as:

yyyy-mm-ddThh:mm:sszzzzzz

where T is the separator between the date and the time, and the time zone is either Z (for UTC) or zzzzzz, which represents ?hh:mm in relation to UTC. For more info on how Time Stamps work see http://kml-samples.googlecode.com. If the time is measured at block support, then:

<TimeStamp><begin> </begin><end> </end></TimeStamp>

tags will be inserted. Temporal support for any spacetime class, if not specified by the user, is determined as a difference between the "time" (indicating begin time) and "endTime" slots.

Author(s)

Tomislav Hengl and Benedikt Gräler

References

See Also

kml_layer.STTDF, plotKML-method

Examples

## Not run: 
data(HRtemp08)

# format the time column:
HRtemp08$ctime <- as.POSIXct(HRtemp08$DATE, format="%Y-%m-%dT%H:%M:%SZ")

# create a STIDF object:
library(spacetime)
sp <- SpatialPoints(HRtemp08[,c("Lon","Lat")])
proj4string(sp) <- CRS("+proj=longlat +datum=WGS84")
HRtemp08.st <- STIDF(sp, time = HRtemp08$ctime, data = HRtemp08[,c("NAME","TEMP")])

# write to a KML file:
HRtemp08_jan <- HRtemp08.st[1:500]
shape <- "http://maps.google.com/mapfiles/kml/pal2/icon18.png"
kml(HRtemp08_jan, dtime = 24*3600, colour = TEMP, shape = shape, labels = "", kmz=TRUE)

## North Carolina SIDS data set:
library(maptools)
fname <- system.file("shapes/sids.shp", package="maptools")[1]
nc <- readShapePoly(fname, proj4string=CRS("+proj=longlat +datum=NAD27"))
time <- as.POSIXct(strptime(c(rep("1974-01-01", length(nc)), 
   rep("1979-01-01", length(nc))), format="%Y-%m-%d"), tz = "GMT")
data <- data.frame(BIR = c(nc$BIR74, nc$BIR79), NWBIR = c(nc$NWBIR74, nc$NWBIR79), 
   SID = c(nc$SID74, nc$SID79))
# copy polygons:
nc.poly <- rep(slot(nc, "polygons"), 2)
# fix the polygon IDs:
for(i in 1:length(row.names(data))) { nc.poly[[i]]@ID = row.names(data)[i] }
sp <- SpatialPolygons(nc.poly, proj4string=CRS("+proj=longlat +datum=NAD27"))
# create a STIDF object:
nct <- STIDF(sp, time = time, data = data)
# write to a KML file:
kml(nct, colour = SID)

## End(Not run)

[Package plotKML version 0.5-6 Index]