Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何访问R中的光栅全局属性?_R_Raster - Fatal编程技术网

如何访问R中的光栅全局属性?

如何访问R中的光栅全局属性?,r,raster,R,Raster,我如何简单地访问光栅“全局属性”(例如,标题或传感器-参见下面的数据结构)上的信息 是否有可能获得与我获得的范围和日期信息相同的信息(见下文) 使用ncdf4包读入.nc文件并浏览 # open nc connection my.nc <- nc_open("./path/thedata.nc") # names of variables names(my.nc$var) # names of attributes of a variable ncatt_get(my.nc,attri

我如何简单地访问光栅“全局属性”(例如,标题或传感器-参见下面的数据结构)上的信息

是否有可能获得与我获得的范围和日期信息相同的信息(见下文)


使用
ncdf4
包读入.nc文件并浏览

# open nc connection
my.nc <- nc_open("./path/thedata.nc")

# names of variables
names(my.nc$var)

# names of attributes of a variable
ncatt_get(my.nc,attributes(my.nc$var)$names[1])

# check the names of dimensions
length(my.nc$dim)
names(my.nc$dim)

# check time dimension of file
my.nc$dim$time
my.nc$dim$time$vals

# global attributes
ncatt_get(my.nc, 0)

# attributes of specific variable
ncatt_get(my.nc, "some_variable")
#打开nc连接

my.nc在寻求帮助时,您应该包括一个简单的示例输入和所需输出,可用于测试和验证可能的解决方案。
> raster[[1]]

class       : RasterLayer 
band        : 1  (of  31  bands)
dimensions  : 110, 74, 8140  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : -42, 32, -55, 55  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : /data/input/raster.nc 
names       : var1 
z-value     : 20667.5 
zvar        : var1 


> raster[1]

[[1]]
File /data/input/raster.nc (NC_FORMAT_CLASSIC):

 2 variables (excluding dimension variables):
    int var1[longitude,latitude,time]   
        units: nodimension
    int var2[longitude,latitude,time]   
        units: nodimension

 3 dimensions:
    longitude  Size:74
        units: degrees east
        long_name: Longitude
    latitude  Size:110
        units: degrees north
        long_name: Latitude
    time  Size:31
        units: Julian days since 1960-1-01

6 global attributes:
    Title: Rain Rate every 1 degree
    Date Beg: 2016-08-01 00:00:00
    Date End: 2016-08-31 23:59:59
    Author: LastName, FirstName
    Sensor: GEO
    Conventions: CF-1.0
# open nc connection
my.nc <- nc_open("./path/thedata.nc")

# names of variables
names(my.nc$var)

# names of attributes of a variable
ncatt_get(my.nc,attributes(my.nc$var)$names[1])

# check the names of dimensions
length(my.nc$dim)
names(my.nc$dim)

# check time dimension of file
my.nc$dim$time
my.nc$dim$time$vals

# global attributes
ncatt_get(my.nc, 0)

# attributes of specific variable
ncatt_get(my.nc, "some_variable")