1

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

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

地图不正确

如果我将函数 image(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 

关于为什么会发生这种情况的任何想法?我想使用光栅版本并将其保存为 geotiff。

4

1 回答 1

0

I was assuming that the netcdf layer was a regular grid and it's not. So coordinate system + transformation is required (thanks to Spacedman at gis.stackexchange.com)

Data provider confirmed EASE coordinate system - EPSG code 3410

The post that helped me with this from Spacedman at https://gis.stackexchange.com/questions/48518/how-to-re-project-ease-equal-area-scalable-earth-grid-with-a-25-km-cylindrica

Now the following seems to work...

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)

Thanks for the help...

Guillermo

于 2013-10-15T17:30:39.593 回答