【问题标题】:plot spatial data from irregular grid从不规则网格绘制空间数据
【发布时间】:2019-09-24 19:41:47
【问题描述】:

我想使用rasterVis 包来绘制空间数据的等高线(例如,使用example 中的levelplot)。但是,数据集来自一个带有不规则网格的NetCDF 文件,如下所示:

lon(y,x) 纬度(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" ;

【问题讨论】:

  • 嗨,安德里亚。欢迎来到 SO!您需要将每个帖子的问题减少到一个,以便获得最佳答案。另外,通过解释你做了什么以及你的预期输出是什么来尽可能地澄清这个问题。

标签: r netcdf rastervis


【解决方案1】:

感谢您的快速反馈。我想用 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 

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

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-02
    • 2017-08-24
    • 2018-08-03
    • 2011-10-20
    • 1970-01-01
    • 2020-09-25
    • 1970-01-01
    相关资源
    最近更新 更多