0

我想使用这个rasterVis包来绘制空间数据的轮廓(例如,在这个例子中使用 levelplot )。但是,数据集来自NetCDF具有不规则网格的文件,如下所示:

lon(y,x) 纬度(y,x) var(y,x)

并且对 lon/lat 隐含的投影没有任何影响。

有没有一种方法可以直接将数据集绘制为这些图中的栅格数据而无需插值?

栅格数据的标题包括网格和投影规范的扩展,这不符合我的问题。栅格不将二维 lon/lat 数组识别为坐标系。

本例中的代码和绘图,但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" ;
4

1 回答 1

0

感谢您的快速反馈。我想用 rasterVis 绘制一个带有不规则网格的 NetCDF(lon、lat 是二维数组):

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)

但是该图不将 lon/lat 地理坐标视为轴,而是将数组的 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 

即“范围”考虑索引而不是坐标。

谢谢

于 2019-05-08T11:06:02.493 回答