我想使用rasterVis
包来绘制空间数据的轮廓(例如,使用example中的levelplot)。但是,数据集来自具有不规则网格的NetCDF
文件,如下所示:
lon(y,x)lat(y,x)var(y,x)
并且与lon / lat所隐含的投影无关。
有没有一种方法可以直接将数据集绘制为栅格数据 像these数字那样没有插值?
栅格数据的标题包括网格和投影规范的扩展,这与我的问题不符。栅格无法将二维lon / lat数组识别为坐标系。
代码和绘图与此example中相同,但netcdf
文件为:
float lat(y, x) ;
lat:standard_name = "latitude" ;
lat:long_name = "Latitude" ;
lat:units = "degrees_north" ;
lat:nav_model = "grid_T" ;
float lon(y, x) ;
lon:standard_name = "longitude" ;
lon:long_name = "Longitude" ;
lon:units = "degrees_east" ;
lon:nav_model = "grid_T" ;
float icethic(time_centered, y, x) ;
icethic:standard_name = "sea_ice_thickness" ;
icethic:long_name = "Ice thickness (cell average)" ;
icethic:units = "m" ;
icethic:online_operation = "average" ;
icethic:_FillValue = 1.e+20f ;
icethic:missing_value = 1.e+20f ;
icethic:coordinates = "time_centered nav_lon nav_lat" ;
答案 0 :(得分:0)
感谢您的快速反馈。我想用rasterVis绘制带有不规则网格(lon,lat是2d数组)的NetCDF:
netcdf temp {
dimensions:
y = 292 ;
x = 362 ;
time_counter = UNLIMITED ; // (1 currently)
variables:
float lat(y, x) ;
lat:standard_name = "latitude" ;
lat:long_name = "Latitude" ;
lat:units = "degrees_north" ;
lat:_CoordinateAxisType = "Lat" ;
float lon(y, x) ;
lon:standard_name = "longitude" ;
lon:long_name = "Longitude" ;
lon:units = "degrees_east" ;
lon:_CoordinateAxisType = "Lon" ;
double time_counter(time_counter) ;
time_counter:standard_name = "time" ;
time_counter:units = "days since 0-00-00 00:00:00" ;
time_counter:calendar = "proleptic_gregorian" ;
float votemper(time_counter, y, x) ;
votemper:standard_name = "Temperature" ;
votemper:long_name = "Temperature" ;
votemper:units = "C" ;
votemper:coordinates = "lon lat time_counter" ;
votemper:_FillValue = 9.96921e+36f ;
votemper:missing_value = 9.96921e+36f ;
votemper:online_operation = "ave(x)" ;
votemper:interval_operation = 3600.f ;
votemper:interval_write = 2678400.f ;
votemper:offline_operation = "ave(x)" ;
}
rasterVis指南启发的代码如下:
library(raster)
library(rasterVis)
stackSIS <- stack("temp.nc")
idx <- c(as.Date('2008-01-15'))
SISmm <- setZ(stackSIS, idx)
names(SISmm) <- month.abb[1]
SISmm
levelplot(SISmm)
,但该图未将经纬度地理坐标视为轴,而是将数组的x,y索引视为轴。确实,当我询问栅格对象的摘要时,我得到了:
class : RasterStack
dimensions : 292, 362, 105704, 1 (nrow, ncol, ncell, nlayers)
resolution : 1, 1 (x, y)
extent : 0.5, 362.5, 0.5, 292.5 (xmin, xmax, ymin, ymax)
coord. ref. : NA
names : Jan
time : 2008-01-15
即“范围”将考虑索引而不是坐标。
谢谢