1

I am trying to plot a very large timeseries charts associated with RasterBrickTimeSeries-class in plotKML. The idea is to divide the RasterBrickTimeSeries into regions, and to use snowfall multicore as well.

A reproducible example is below:

library(plotKML)
library(raster)
library(sp)
library(snowfall)
data(LST)
setwd("/Users/x/test")
#create a sample point for each cell
pnts <- LST[,47:48] # lon and lat columns
pnts <- cbind(1:nrow(pnts), pnts)
coordinates(pnts) <- ~lon + lat
proj4string(pnts) <- CRS("+proj=longlat +datum=WGS84")

gridded(LST) <- ~lon+lat
proj4string(LST) <- CRS("+proj=longlat +datum=WGS84")
dates <- sapply(strsplit(names(LST), "LST"), function(x){x[[2]]})
datesf <- format(as.Date(dates, "%Y_%m_%d"), "%Y-%m-%dT%H:%M:%SZ")
## begin / end dates +/- 4 days:
TimeSpan.begin = as.POSIXct(unclass(as.POSIXct(datesf))-4*24*60*60, origin="1970-01-01") 
TimeSpan.end = as.POSIXct(unclass(as.POSIXct(datesf))+4*24*60*60, origin="1970-01-01")
## get the dates from the file names:
LST_ll <- brick(LST[1:5])
LST_ll@title = "Land Surface Temperature images"
LST.ts <- new("RasterBrickTimeSeries", variable = "LST", sampled = pnts, 
              rasters = LST_ll, TimeSpan.begin = TimeSpan.begin[1:5], 
              TimeSpan.end = TimeSpan.end[1:5])
data(SAGA_pal)
## plot images in Google Earth:
plotKML(LST.ts, colour_scale=SAGA_pal[[1]])

Till here the code is fine, a chart is plotted for each point

Trying the kml.tiles on pnts works:

tiles.LST.ts <- kml.tiles(pnts, block.x=0.05,
                     size=0.4)

Tiles are produced and work fine, but of course it plots only the point locations not the actual charts.

I am not much interested in plotting the raster themselves, rather the timeseries charts only. Hence, plotKML.GDALobj might not be the best option

Is there a way to use kml.tiles on the LST.ts (i.e. RasterBrickTimeSeries) to plot the timeseries charts in parallels and regions?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.