从R中的NetCDF文件中提取特定于站点的信息 [英] Extracting site-specific information from NetCDF file in R

查看:288
本文介绍了从R中的NetCDF文件中提取特定于站点的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从德国气象局获得了有关欧洲平均气温的NetCDF文件(

I got a NetCDF file from the German Meteorological Service concerning mean temperatures in Europe (CDC FDP SERVER). The only thing I want to extract is the daily mean temperature for Bornholm, which is an island in the central Baltic.

我知道如何提取某些坐标的信息(请参见下面的代码示例).唯一的问题是文件的特定坐标是旋转的",这就是为什么Bornholm(从GoogleMaps提取)的地理坐标有点用的原因.

I know how to extract information for certain coordinates (see code sample below). The only problem is that the file specific coordinates are 'rotated' which is why the geographic coordinates for Bornholm (extracted from GoogleMaps) are kind of useless.

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使用了Mercator投影的近似变体.因此,如何转换NetCDF文件或GoogleMaps中的坐标,以便可以找到所需的内容.我可以打赌,那里有一个简单的解决方案,但不幸的是没有-至少我找不到一个解决方案.

To cut it short - Google uses a close variant of the Mercator projection. So how can I either convert the NetCDF file or the coordinates from GoogleMaps, so that I can find what I need. I could have bet that there's a simple solution out there but unfortunately not - at least I couldn't find one.

有关print(temp)生成的文件的信息,请参见以下内容:

For information about the file generated by print(temp) see below:

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

感谢您的帮助.非常感谢...

Any help is appreciated. Thanks a lot...

推荐答案

您加载了栅格数据包,但没有使用它.您是否尝试过类似以下的内容?

You load the raster package, but you do not use it. Have you tried something like the below?

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

这篇关于从R中的NetCDF文件中提取特定于站点的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆