NSIDC海冰.bin文件到raster() [英] NSIDC sea ice .bin file to raster()

查看:92
本文介绍了NSIDC海冰.bin文件到raster()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照示例在此处在极地例子"下

I am trying to follow the example give here under "A polar example"

本示例使用.bin格式的海冰数据将其绘制为栅格.我正在尝试使用国家冰雪数据中心的原始ftp服务器.因此,我认为应该没有问题.但是,当我尝试提示R时,请运行以下脚本

This example uses sea-ice data in .bin format to plot as raster. I am trying the same with a different file available from the original ftp server of the National Snow and Ice Data Center. Hence, I assume there should be no issue. However, when I try to prompt R run the following script

# from NSIDC sea ice concentration file
baseurl <- "ftp://sidads.colorado.edu/pub/DATASETS/"

f2 <- paste(baseurl, 
        "nsidc0051_gsfc_nasateam_seaice/final-gsfc/north/daily/2013/nt_20130111_f17_v1.1_n.bin",
        sep='')

if (!file.exists(basename(f2))) download.file(f2, basename(f2), mode = "wb")
ice2 <- raster(basename(f2))

.rasterObjectFromFile(x,band = band,objecttype ="RasterLayer",时出错:无法从此文件创建RasterLayer对象.

Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", : Cannot create a RasterLayer object from this file.

我要去哪里错了?.bin文件损坏了?任何帮助表示赞赏!

Where am I going wrong? is the .bin file corrupted? Any help appreciated!

谢谢!

推荐答案

好的,在github上找到了一个非常不错的解决方案.

ok, found a solution on github that works really nice.

https://github.com/cran/raster/blob/master/R/nsidcICE.R

只需替换脚本的第14行

Just replace in line 14 of the script

hemi <- tolower(substr(bx, 21L, 21L)) 

通过

hemi <- tolower(substr(bx, 22L, 22L)),

由于新名称结构与原始名称结构略有不同,在v1.1序列中仅点一个点!

as the new name structure differs slightly from the original one by one digit namly a dot in the v1.1 sequence!

比较:

"nt_19781119_f07_v01_s.bin" 

升级到我感兴趣的版本

"nt_20130111_f17_v1.1_n.bin"

这篇关于NSIDC海冰.bin文件到raster()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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