时空K函数等值线图

时间:2013-11-28 04:27:19

标签: r matlab

随着时间的推移,我有纬度和经度点数据。我想绘制(在R或Matlab中)时空K函数的等高线图(很像下面的那个),但不知道如何。任何建议都会很棒!enter image description here

3 个答案:

答案 0 :(得分:3)

以下是使用stkhat包中的splancs函数计算时空K函数的方法。我在时空立方体上制作一些随机数据,然后计算最大0.3个距离单位和0.3个时间单位的空间范围的起音时间K函数估计。

> require(splancs)
> xyt=matrix(runif(3000),ncol=3)
> poly=bboxx(spoints(c(0,1,0,1)))
> tlim=c(0,1)
> s=seq(0,.3,len=51)[-1]
> t=s
> stk = stkhat(xyt[,1:2], xyt[,3], poly, tlim, s,t)
> image(str$kst)
> require(lattice)
> image(x=stk$s, y=stk$t,z = stk$kst)

答案 1 :(得分:2)

以下是R中如何开始此操作的大纲。请注意,这并未解决“如何计算空间 - 时间K函数”的问题。

首先,从plot raster with discrete colors using rasterVis

获取示例数据
x=seq(-107,-106,.1)
y=seq(33,34,.1)
coords=expand.grid(x,y)
data1=data.frame(coords,depth=runif(nrow(coords),0,2))
names(data1)=c('x','y','value')

# get max and min values 
xmn=min(data1[,1]); xmx=max(data1[,1])
ymn=min(data1[,2]); ymx=max(data1[,2])

现在从原始数据计算插值栅格......

# compute interpolated raster. Note that this is not the 'spatial-temporal K function' requested in the question, as pointed out in a comment below, but a linear interpolation
library(akima)
akima.li <- interp(data1[,1], data1[,2], data1[,3], duplicate = "median",
                   xo=seq(xmn,xmx, length=100),
                   yo=seq(ymn,ymx, length=100))

绘制栅格......

# plot interpolated raster 
image(akima.li, col = rainbow(100, alpha = 1))

enter image description here

将栅格绘制为等高线图...

# plot interpolated contour 
contour(akima.li, nlevels = 3)

enter image description here

现在将光栅和轮廓放在一起,这就是您发布的示例图像...

# put the raster and contours together
image(akima.li, col = rainbow(100, alpha = 1))
contour(akima.li, nlevels = 3, add = TRUE)

enter image description here

通过一些小调整,这里与示例的风格非常接近......

image(akima.li, col = gray.colors(10, start = 0, end = 0.9, gamma = 2.2, alpha = 1))
contour(akima.li, nlevels = 3, add = TRUE)

enter image description here

最后,这几乎是一个匹配,灰度轮廓填充,轮廓标签,但没有轮廓线

image(akima.li, col = gray.colors(10, start = 0, end = 1, gamma = 1, alpha = 1))
contour(akima.li, nlevels = 3, add = TRUE, lty = 0)

enter image description here

答案 2 :(得分:0)

好吧,我偶然发现了你的问题,因为我现在正在处理这种分析。我不知道你是否还需要答案,但计算它的一种方法是在R中使用stpp包。

该函数名为STIKhat,您可以使用plotK绘制它。

文档为here。它很容易遵循这就是为什么我不把它放在这里。希望它可以帮助那些可能有同样问题的人!