【问题标题】:Extracting site-specific information from NetCDF file in R从 R 中的 NetCDF 文件中提取特定于站点的信息
【发布时间】:2016-12-31 14:54:33
【问题描述】:

我从德国气象局获得了一份关于欧洲平均温度的 NetCDF 文件 (CDC FDP SERVER)。我唯一想提取的是波罗的海中部岛屿博恩霍尔姆的每日平均温度。

我知道如何提取特定坐标的信息(参见下面的代码示例)。唯一的问题是文件特定的坐标是“旋转的”,这就是为什么 Bornholm 的地理坐标(从 GoogleMaps 中提取)有点没用。

packages <- c("RNetCDF",
              "ncdf4",
              "raster")

lapply(packages, require, character.only = TRUE)

x <- mean(14.68,15.16)        #coordinates for a rectangle around 
y <- mean(54.987,55.299)      #Bornholm extracted from GoogleMaps

temp <- nc_open("tas_decreg_europe_v20140120_20030101_20030131.nc")
temp

var <- ncvar_get(temp, "tas")
point <- var[x,y,]
as.data.frame(point)

简而言之 - Google 使用墨卡托投影的近似变体。那么如何转换 NetCDF 文件或 GoogleMaps 中的坐标,以便找到我需要的东西。我可以打赌那里有一个简单的解决方案,但不幸的是没有 - 至少我找不到。

关于print(temp)生成的文件的信息见下文:

File tas_decreg_europe_v20140120_20030101_20030131.nc (NC_FORMAT_CLASSIC):

     2 variables (excluding dimension variables):
        char rotated_pole[]   
            grid_mapping_name: rotated_latitude_longitude
            grid_north_pole_latitude: 39.25
            grid_north_pole_longitude: -162
        float tas[lon,lat,time]   
            long_name: Near-Surface Air Temperature
            units: K
            grid_mapping: rotated_pole
            _FillValue: 1.00000002004088e+20
            missing_value: 1.00000002004088e+20

     3 dimensions:
        lon  Size:1056
            standard_name: grid_longitude
            long_name: longitude
            units: degrees_east
            axis: X
        lat  Size:1026
            standard_name: grid_latitude
            long_name: latitude
            units: degrees_north
            axis: Y
        time  Size:31   *** is unlimited ***
            standard_name: time
            units: days since 2003-01-01 00:00:00
            calendar: standard

感谢任何帮助。非常感谢...

【问题讨论】:

  • 它没有保存我的“大家好...”,所以:“大家好...”

标签: r netcdf netcdf4


【解决方案1】:

您加载了光栅包,但没有使用它。您是否尝试过类似以下的方法?

library(raster)  
x <- mean(14.68,15.16)  
y <- mean(54.987,55.299)
temp <- brick("tas_decreg_europe_v20140120_20030101_20030131.nc", var='tas')
extract(temp, cbind(x,y))

【讨论】:

  • 绝对是提取数据的正确方法,但仍仅显示 NA。也难怪如果范围不能包含我的坐标 (extent : -28.342, 18.122, -23.342, 21.802 (xmin, xmax, ymin, ymax))。所以,似乎我仍然需要转换已经提到的东西。有什么进一步的建议...?
  • 这些坐标显然不是欧洲任何地方的标准坐标,所以实际上它们似乎使用了与(格林威治,赤道)不同的原点,换句话说,旋转(或者可能是投影? )。但是,如果您不告诉我们,我无法猜测这种轮换是什么。他们的网站上可能有一些文档。或者当你做print(temp)时可能有信息
  • 这就是我提供文件链接的原因。无论如何,我只是将 print(temp) 生成的信息添加到原始问题中(见上文)。网站上的数据集描述说的差不多。干杯
  • 你下载了,但我无法从我所在的位置下载它(我也不应该)。
猜你喜欢
  • 2022-12-17
  • 1970-01-01
  • 2015-09-08
  • 1970-01-01
  • 1970-01-01
  • 2011-12-26
  • 1970-01-01
  • 1970-01-01
  • 2021-11-12
相关资源
最近更新 更多