从 R 中的 NetCDF 文件中提取特定于站点的信息

Extracting site-specific information from NetCDF file in R

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

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

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

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

您加载了栅格包,但没有使用它。您尝试过类似下面的方法吗?

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))