如何使用ncdf4代码将hdf5数据转换为栅格

时间:2020-02-11 18:28:35

标签: r raster hdf5 hdf ncdf4

我有hdf5数据,我尝试使用nc代码将variabe提取到栅格中。当我尝试制作如图所示的栅格时,在代码的最后一行出现了错误。 min(lat)也显示为NAN为什么? Output

library(sp)
library(sf)
library(gdalUtilities)
library(rgdal)      
library(rungdal)
library(tiff)
library(ncdf4)
library(hdf5r)
library(hdfqlr)
library(BiocManager)
#BiocManager::install("rhdf5")
#source("http://bioconductor.org/biocLite.R")
#biocLite("rhdf5")
library(rhdf5)
library(gdalUtils)
library(raster)
library(maps)
library(sf)
library(fields)
library(maptools)
library(ncdf4)
library(ncdf.tools)
library(ncdfgeom)
data(wrld_simpl)
options(max.print = 99999999)
library(sp)
data(meuse)
coordinates(meuse) <- ~x+y
#library(ncdf.tools)
#library(latticeExtra)
setwd("D://2R")
fname = '1C.F19.SSMIS.XCAL2016-V.20150906-S011918-E030110.007356.V05A.hdf5'
ncin <- nc_open(fname)
ncin
print(ncin)
lon <- ncvar_get(ncin, "S1/Longitude")
lat <- ncvar_get(ncin, "S1/Latitude")
a_unit <- ncatt_get(ncin,"S1/Tc","units")
canopy.array <- ncvar_get(ncin, "S1/Tc")
dim(canopy.array)
fillvalue <- ncatt_get(ncin, "S1/Tc", "_FillValue")
nc_close(ncin)
a <- raster(canopy.array, xmn=min(lon), xmx=max(lon), ymn=min(lat), ymx=max(lat), crs=CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs+ towgs84=0,0,0"))
min(lon)

0 个答案:

没有答案