kml_layer.STIDF {plotKML}R Documentation

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


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.


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



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


temporal support (point or block) expressed in seconds


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


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:


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


Tomislav Hengl and Benedikt Gräler


See Also

kml_layer.STTDF, plotKML-method


## Not run: 

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

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

# write to a KML file:
HRtemp08_jan <-[1:500]
shape <- ""
kml(HRtemp08_jan, dtime = 24*3600, colour = TEMP, shape = shape, labels = "", kmz=TRUE)

## North Carolina SIDS data set:
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]