为什么使用 R 包栅格绘制具有"image(x,y,z)"和"plot (raster)"的 NetCDF 图层时会得到不同的结果?



这可能是一个非常简单的问题。

我想使用函数图(栅格(在地图上绘制来自 NetCDF 文件的数据图层。我不知道为什么我会得到光栅偏斜/偏移(我的猜测是问题出在转换、分辨率上? 如下图所示。

地图不正确

如果我将函数图像(x,y,z...(与纬度,lng,值矩阵一起使用,我会得到正确的显示,如下所示:

正确的地图

这是我正在使用的 R 中的代码:

library(ncdf)
library(raster)
# This is opening the NetCDF layer as a raster
varRaster<-raster("SMOS_File.nc", varname="Soil_Moisture")
# Showing the information of the raster
varRaster
class       : RasterLayer 
dimensions  : 586, 1383, 810438  (nrow, ncol, ncell)
resolution  : 0.2603037, 0.2916659  (x, y)
extent      : -180, 180, -85.4581, 85.4581  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : SMOS_File.nc 
names       : Retrieved.soil.moisture.value 
zvar        : Soil_Moisture 
plot(varRaster)
data(wrld_simpl)
plot(wrld_simpl, add = TRUE) #This produces the incorrect map 
# If I use the "image" function I can get the right overlay of the data
ex.nc = open.ncdf("SMOS_File.nc")
print(ex.nc)
summary(ex.nc)
y = get.var.ncdf( ex.nc, "lat")  
x = get.var.ncdf( ex.nc, "lon")
z = get.var.ncdf( ex.nc, "Soil_Moisture")
image(x,y,z, zlim=c(-0.9,1), col = heat.colors(37))
plot(wrld_simpl, add = TRUE) #This produces the correct map 

知道为什么会发生这种情况吗? 我想使用光栅版本并将其另存为geotiff。

我假设netcdf层是一个规则的网格,但事实并非如此。 所以坐标系+变换是必需的(感谢 gis.stackexchange.com 的Spacedman(

数据提供者确认 EASE 坐标系 - EPSG 代码 3410

帮助

我解决这个问题的帖子 Spacedman 在 https://gis.stackexchange.com/questions/48518/how-to-re-project-ease-equal-area-scalable-earth-grid-with-a-25-km-cylindrica

现在以下似乎有效...

library(ncdf)
library(raster)
library(maptools)
source("http://dl.dropboxusercontent.com/u/3394649/R_libs/ConversionFunctions.R") #Thanks to Spacedman at  https://gis.stackexchange.com/questions/48518/how-to-re-project-ease-equal-area-scalable-earth-grid-with-a-25-km-cylindrica
data(wrld_simpl)
varRaster <- ConvertGrid("SMOS_File.nc", "Soil_Moisture")
varRaster[varRaster < 0 ] <- NA
varRaster <- TransformTo(varRaster)
#With Plot
plot(varRaster)
plot(wrld_simpl, add = TRUE)
#Now with 'image'
image(varRaster, useRaster=TRUE)
plot(wrld_simpl, add = TRUE)

感谢您的帮助...

吉列尔莫

最新更新