如何使用R将Grib1转换为Netcdf? [英] how to convert Grib1 to Netcdf using R?

查看:310
本文介绍了如何使用R将Grib1转换为Netcdf?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了一些grib格式的气候数据.我想使用"R"将其转换为NetCDF格式.

I have just downloaded some climate data in grib format. I want to use "R" to convert it to NetCDF format.

此外,由于文件由不同的变量组成,我想一次将一个变量提取到单个文件中.

Furthermore, as the file consists of different variables, I would like to extract one variable at a time into individual files.

推荐答案

如果没有您的特定文件,很难回答这个问题.您应该考虑制作可复制的示例,尤其是如果您重新发布到R板.

It's hard to answer this without your specific file. You should look into producing reproducible examples, especially if you're posting to the R board.

对于R,签出library(raster)library(ncdf4).我只是获取了我看到的第一个grib1文件,并整理了一个简单的示例.

For R, check out library(raster) and library(ncdf4). I just grabbed the first grib1 file I saw, and put together a quick example.

library(raster)
library(ncdf4)

download.file(url = 'ftp://ftp.hpc.ncep.noaa.gov/grib/20130815/p06m_2013081500f030.grb', destfile = 'test.grb')

(r <- raster('test.grb'))

n <- writeRaster(r, filename = 'netcdf_in_youR_comp.nc', overwrite = TRUE)

这篇关于如何使用R将Grib1转换为Netcdf?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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