-1

如何在 netcdf 文件中进行逆坐标变换?我有一个包含 75 个经度值和 36 个纬度值的网格:

nc<-create.n("filename.nc")
#Dimentions
dim.def.nc(nc,"lon",75)
dim.def.nc(nc,"lat",36)
dim.def.nc(nc,"time",365)
#Vars
var.def.nc(nc,"Observation","NC_FLOAT", c(1,0,2))
var.def.nc(nc,"lon","NC_FLOAT", c(0))
var.def.nc(nc,"lat","NC_FLOAT", c(1))
var.def.nc(nc,"time","NC_FLOAT", c(2))
(...)

根据unidata中的文档,应该可以让 netcdf 进行从 (lat,lon) 到 (x,y) 的逆变换,但我不知道如何执行此操作。我想将我的 lat long 网格转换为 Lambert Conformal 网格。

4

1 回答 1

4

这是我自己重新投影 netCDF 文件的方式:基本上我获取经度、纬度和我想要的数据并创建一个 shapefile,然后我可以使用包rgdal和. (此处的示例使用从 NOAA 下载的数据)spmaptools

library(ncdf)
library(rgdal)
library(sp)
library(maptools)
nc <- open.ncdf("20130128-ABOM-L4HRfnd-AUS-v01-fv01_0-RAMSSA_09km.nc")

# Grab the longitude, latitude and data
lon <- nc$dim$lon$vals
lat <- nc$dim$lat$vals
sst <- get.var.ncdf(nc,"analysed_sst")

# Create a SpatialPointsDataFrame object
lonlat <- expand.grid(lon,lat)
sst <- as.data.frame(matrix(sst,ncol=1))
dat <- SpatialPointsDataFrame(lonlat, data=sst,
                              proj4string=CRS("+proj=longlat +datum=WGS84 "))

# And then reproject
dat2 <- spTransform(dat,CRS("+proj=lcc"))  
# Of course you have to write the proj4 string that corresponds exactly to the desired projection.
于 2013-01-29T16:44:36.160 回答