为什么在绘制NetCDF图层时使用“;图像(x,y,z)";及;绘图(光栅)";使用R-package光栅?

为什么在绘制NetCDF图层时使用“;图像(x,y,z)";及;绘图(光栅)";使用R-package光栅?,r,plot,raster,netcdf,geotiff,R,Plot,Raster,Netcdf,Geotiff,这可能是一个很容易解决的问题 我想使用函数plot(光栅)在地图上绘制NetCDF文件中的数据层。我不知道为什么会出现光栅倾斜/偏移(我猜问题在于变换、分辨率?),如下图所示 如果我将函数图像(x、y、z…)与lat、lng、值矩阵一起使用,我会得到正确的显示,如下所示: 这是我正在使用的R中的代码: library(ncdf) library(raster) # This is opening the NetCDF layer as a raster varRaster<-rast

这可能是一个很容易解决的问题

我想使用函数plot(光栅)在地图上绘制NetCDF文件中的数据层。我不知道为什么会出现光栅倾斜/偏移(我猜问题在于变换、分辨率?),如下图所示

如果我将函数图像(x、y、z…)与lat、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 
库(ncdf)
图书馆(光栅)
#这将以光栅形式打开NetCDF层

varRaster我假设netcdf层是一个规则网格,而不是。因此需要坐标系+转换(感谢位于gis.stackexchange.com的Spacedman)

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

从Spacedman在

现在,下面的方法似乎奏效了

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)
库(ncdf)
图书馆(光栅)
图书馆(地图工具)
来源(“http://dl.dropboxusercontent.com/u/3394649/R_libs/ConversionFunctions.R)感谢Spacedman在https://gis.stackexchange.com/questions/48518/how-to-re-project-ease-equal-area-scalable-earth-grid-with-a-25-km-cylindrica
数据(wrld_siml)

varRaster检查
wrld\u siml
对象的范围、分辨率和投影。我最好的猜测是分辨率不匹配。我没有看到任何数字(链接不起作用)。您是否尝试过
image(t(…)
?同时发布
SMOS_文件.nc
会很有帮助。[link](SMOS_文件.nc)[link](SMOS_文件.nc)上面的图像现在正常工作。实际上,当我使用“图像”时,我可以在地图上正确显示数据。我试图解决的问题是如何在地图上正确显示此netcdf层。我已经将光栅保存为geotiff,并尝试在另一个软件GRASS和ArcMap中显示它,这两个软件中的地图看起来完全相同。我认为转换是在调用“光栅”函数时发生的。