从paleoView导入R中的netcdf时,只有正纬度和经度可能是错误的投影 [英] Only positive latitude and longitude when importing netcdf in R from paleoView probably wrong projection

查看:174
本文介绍了从paleoView导入R中的netcdf时,只有正纬度和经度可能是错误的投影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 paleoview 软件从过去下载了一些变量气候,包括平均温度15000BP-10000BP(我可以根据要求上传文件,但至少为GB).

I used the paleoview software to download some variables from past climate, including the mean temperature from 15000BP-10000BP (I could upload a file on request but its a GB at least).

主要问题是,当我阅读栅格时,它仅包含正纬度和正经度.我从这篇文章中知道分辨率为2.5 * 2.5.

The main problem is that when I read the raster, it contains only positive latitude and positive longitude. I know from the article that this has a 2.5*2.5 resolution.

我同时加载了raster和ncdf4库以使用raster进行读取

I loaded both the raster and ncdf4 libraries to read it using raster

library(raster)
library(ncdf4)

当我使用以下代码阅读时

When I read it using the following code

r <- raster("mean_temperature-15000BP-10000BP.nc",  varname = "14000BP-13000BP/13300BP")

我得到以下信息

r
class       : RasterLayer 
band        : 1  (of  12  bands)
dimensions  : 72, 144, 10368  (nrow, ncol, ncell)
resolution  : 1, 1  (x, y)
extent      : 0.5, 144.5, 0.5, 72.5  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
names       : Mean.Temperature 
z-value     : 1 
zvar        : 14000BP-13000BP/13300BP 

如您所见,范围仅是正数,但是我知道它具有整个世界的数据,当我绘制地图时,我得到以下图像:

As you see the extent is only positive, but I know it has the data for the whole world, when I plot the map I get the following image:

plot(r)

清楚地显示了极圈温度极低且南极洲比北极更大的预期模式.

which clearly shows the patterns expected with the polar circles having extremely low temperatures and the Antarctica being larger that the arctic.

显然+ proj = longlat + datum = WGS84 + ellps = WGS84 + towgs84 = 0,0,0在这里是错误的,我想如果我弄清楚实际的坐标是什么. 我可以重新投影并以正确的格式获取栅格

clearly the +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 is wrong here, and I think that if I figure out whats the actual coord. ref. I could reproject it and get the raster in the right format

我尝试使用ncdf4软件包尝试从该层获取更多信息,这就是我所做的:

I tried working with the ncdf4 package to try to get more info from the layer, and this is what I did:

nc <- nc_open("mean_temperature-15000BP-10000BP.nc")

使用nc_open函数读取图层后,我看到了变量的名称,试图理解更多的图层,在这里,我显示了前10个

After reading the layer using the nc_open function I see the names of the variables to try to understand more of the layers, here I show the first 10

names(nc$var)[1:10]

[1] "window"                  "width"                   "decimals"                "months"                  "latitudes"               "longitudes"              "15100BP-15000BP/15100BP" "15100BP-15000BP/15099BP"
[9] "15100BP-15000BP/15098BP" "15100BP-15000BP/15097BP"

因此,如果我继续查找并转到经纬度名称,则会得到:

So if I keep looking and go to the latitude and longitude names I get:

ncatt_get(nc, attributes(nc$var)$names[5])
$units
[1] "degrees north"

ncatt_get(nc, attributes(nc$var)$names[6])
$units
[1] "degrees east"

关于如何重新投影此栅格以得到+ proj = longlat + ellps = WGS84 + datum = WGS84 + no_defs +的-90、90和-180至180的经度的任何想法towgs84 = 0,0,0投影

Any idea on how to reproject this rasters to get a latitude that goes from -90, 90 and longitude from -180 to 180 that you would expect in a +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0 projections

推荐答案

要解决此问题,您可以设置范围:

To fix this, you could set the extent:

library(raster)
r <- raster("mean_temperature-15000BP-10000BP.nc",  varname = "14000BP-13000BP/13300BP")
extent(r) <- c(-180,180,-90,90)

但是请注意,有时气候数据的经度从0到360(我认为不是在这里):

But note that sometimes longitude in climate data goes from 0 to 360 (not here, I think):

extent(r) <- c(0,360,-90,90)
r <- rotate(r)

要了解有关ncdf中内容的更多信息,您可以

To see more about what's in the ncdf, you can do

print(r)

当然,您只想这样做是因为您确实对范围有把握,并且您可能想联系数据提供商以报告此问题.

Of course you only want to do this is you are really sure about the extent, and you may want to contact the data provider to report this issue.

这篇关于从paleoView导入R中的netcdf时,只有正纬度和经度可能是错误的投影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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