我有记录数量、纬度、截止日期和日期的数据。我的目标是使用Google Viz或Shiny来创建一个带有时间序列滚动条的地图。下面是我的data.frame在R中的一个示例。
date lat lon num
[1,] 14785 33.47350 -82.01051 174
[2,] 14794 32.75549 -97.33077 904
[3,] 14680 33.74900 -84.38798 7
[4,] 14762 42.90261 -78.74457 1
[5,] 14762 42.01114 -87.84062 1
[6,] 14767 36.37285 -94.20882 152到目前为止,我已经能够生成以下所有事件的映射,但它不包括时间部分。
library(maps)
map('state',plot = TRUE,col = "grey",fill = F)
points(x = toy$lon, y = toy$lat, col = toy$recs)
title("Events Across America")我对制作带有时间序列滚动条的交互式地图很感兴趣,如下图所示:http://shiny.rstudio.com/gallery/google-charts.html
我已经使用{space}和{spacetime}库创建了一个时空对象,但是我不知道如何用滚动条来可视化它。这个是可能的吗?任何在GoogleViz或Shiny中的东西都会很棒。
#### Toy example: ####
toy <- as.data.frame(toy)
toy <- toy[order(toy$date,decreasing = F),]
coordinates(toy) <- c("lat","lon")
sp <- SpatialPoints(toy)
# Building a spatial data frame:
sp.df <- SpatialPointsDataFrame(sp, data.frame(recs = toy$recs,date = toy$date))
summary(sp.df)
# Building a Space-time data frame.
time <- as.POSIXct(toy[["date"]], tz = "GMT")
# to build a space-time object
# data1 has to have sp_n * time_m = n*m rows corresponding to the observations
data1 <- data.frame(recs = rpois(nrow(toy)^2,100))
sptdat <- STFDF(sp,time,data1)发布于 2015-12-16 00:35:00
我使用了plotKML包(https://cran.r-project.org/web/packages/plotKML/index.html)来可视化我的STIDF点对象。plotKML函数可以读取使用spacetime包创建的对象。它创建了一个可以在Google Earth中读取的kml文件。谷歌地球有一个时间滑块,你可以用它轻松地评估你的时空数据。既可以使用光栅数据也可以使用矢量数据。
https://stackoverflow.com/questions/28576728
复制相似问题