阅读Netcdf子类别并转换为网格 [英] Read Netcdf sub categories and convert to grid

查看:120
本文介绍了阅读Netcdf子类别并转换为网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也在堆栈gis 变量.我也想阅读它们并转换为栅格网格,但是栅格似乎不支持netcdf4.我感谢任何建议.

I also posted this question on stack gis 1. From the netcdf4 data that have sub categories, I want to be able to read "Retrieval/fs" variable. I also want to read them and convert to raster girds, but it seems that raster doesn't support netcdf4. I appreciate any suggestions.

library(ncdf4)
library(raster)
file <- "http://140906_B7101Ar_150909171225s.nc4"

names(file$var)
"latitude" ... "longitude"... "Retrieval/fs"

lat <- raster(file, varname="latitude")
lon <- raster(file, varname="longitude")

Error in (function (classes, fdef, mtable)  :
unable to find an inherited method for function ‘raster’ for signature ‘"ncdf4"’

推荐答案

以下是我提出的问题的答案.由于数据未网格化,因此我检索lon和lat信息以及变量以创建数据框.

Here is the answer to the question I asked. Since the data is not gridded, I retrieve the lon and lat information along with the variables to create a dataframe.

fs <- ncvar_get(ncfile, "Retrieval/fs")
xlon <- ncvar_get(ncfile, "longitude")
xlat <- ncvar_get(ncfile, "latitude")
d <- data.frame( as.vector(xlon),as.vector(xlat), as.vector(fs))# create a dataframe
coordinates(d) <- c("xlon","xlat")
proj4string(d) <- CRS("+proj=longlat") 
spoint <- SpatialPoints(coords = d) #create a spatial point object

这篇关于阅读Netcdf子类别并转换为网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆