将网格3D数据插值到更精细的比例 [英] Interpolating Gridded 3D Data to a finer scale

查看:196
本文介绍了将网格3D数据插值到更精细的比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个概率面的NetCDF文件.这是一个0.25度经度/纬度间隔的30x30网格,其概率表面以z维表示.我可以轻松地将其导入NetCDF查看器Panoply:

I have a NetCDF file of a probability surface. It's a 30x30 grid of 0.25 degree lat/lon intervals with a probability surface described in the z dimension. I can easily import this into Panoply, a NetCDF viewer:

然后轻而易举(选中一个框)即可将原始数据插值/平滑为更细的网格大小:

And it's then a breeze (checking one box) to interpolate/smooth the raw data to a finer grid size:

但是,我不仅要可视化数据,还想将其与测深法和点数据一起绘制在R中.一切都没问题,但是我还没有找到在R中插入网格化数据的直接方法.这是我用来导入和绘制数据的代码:

However, I don't just want to visualize the data, I want to plot it in R along with bathymetry and point data. That all is no problem, but I have not found a straightforward way to interpolate the gridded data in R. Here's the code I use to import and plot the data:

library(RNetCDF)

nc <- open.nc("132235-1.nc")
print.nc(nc)
tmp <- read.nc(nc)
probs<-tmp$likelihoods

xran <- range(tmp$longitude)
yran <- range(tmp$latitude)
zran <- range(probs,na.rm=T)
lon <- tmp$longitude
lat <- tmp$latitude[30:1]

z <- array(probs, dim=dim(probs))

z <- z[,rev(seq(ncol(z)))]
z <- z[,seq(ncol(z))]



prob.pal<-colorRampPalette(
  c("#C1FFC1","#8FBC8F","#2F4F4F")
)

zbreaks <- seq(0.0001, 0.063, by=0.001)

cols<- c(prob.pal(length(zbreaks)-1))

png("ProbTest.png", width=7.5, height=6, units="in", res=200)
layout(matrix(1:2, 1,2), widths=c(6,1.5), heights=c(6))

par(mar=c(2,2,1,1), ps=10)
image(lon, lat, z=z, col=cols, breaks=zbreaks, useRaster=TRUE, ylim=c(13,28), xlim=c(-115,-100))

dev.off()

最后我得到了这一结果,它与使用Panoply相同,但是具有不同的配色方案:

And I end up with this, which is the same as using Panoply but with a different color scheme:

是否有直接的方法来插值/平滑此数据?我知道如何使用点数据而不是网格数据来创建内核利用率密度等.

Is there a straightforward way to interpolate/smooth this data? I know how to create kernel utilization densities etc. using point data, but not using gridded data.

非常感谢您的协助!

推荐答案

这是我认为您正在寻找的解决方案,它使用双线性重采样.但这不是进行这种插值的唯一方法,您可能需要证明不使用更复杂的方法(例如,地统计,样条线等):

This is the solution I think you're looking for, which uses bilinear resampling. However this is not the only way to do such interpolation and you'd likely need to justify not using a more sophisticated approach (e.g. geostatistical, splines, etc.):

library(raster)
set.seed(2002)

##  Create an extent boundary:
ex <- extent(c(0, 20, 0, 20))

##  Simulate a coarse raster:
r.small <- raster(ex, vals=rnorm(10*10, mean=5, sd=1), nrow=10, ncol=10)

##  Simulate the grid of a finer-scale raster:
r.big <- raster(ncol=200, nrow=200, ext=ex)

##  Resample the coarser raster to match finer grid:
r.res <- resample(x=r.small, y=r.big, method="bilinear")

plot(r.small)
plot(r.res)

粗略:

好:

这篇关于将网格3D数据插值到更精细的比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆