问题描述
我确信在某个地方可以找到这个确切的应用程序,但我没有找到。
File filname.nc (NC_FORMAT_CLASSIC):
3 variables (excluding dimension variables):
float xlat[jx,iy]
long_name: Latitude on Cross Points
standard_name: latitude
units: degrees_north
grid_mapping: crs
float xlon[jx,iy]
long_name: Longitude on Cross Points
standard_name: longitude
units: degrees_east
grid_mapping: crs
float count[jx,iy,time]
cell_methods: time: point
grid_mapping: crs
coordinates: xlat xlon
units: particles m-3
standard_name: near-surface_particle_count
long_name: Near-surface particle count
3 dimensions:
time Size:7273 *** is unlimited ***
long_name: time
standard_name: time
units: hours since 1949-12-01 00:00:00 UTC
calendar: gregorian
bounds: time_bnds
iy Size:141
long_name: y-coordinate in Cartesian system
standard_name: projection_y_coordinate
units: m
axis: Y
_CoordinateAxisType: GeoY
jx Size:240
long_name: x-coordinate in Cartesian system
standard_name: projection_x_coordinate
units: m
axis: X
_CoordinateAxisType: GeoX
data <- nc_open('filename.nc')
## Get lats and long
lat <- ncvar_get(data,varid = 'xlat')
lon <- ncvar_get(data,varid = 'xlon')
dim(lat)
### Get the dates and convert them.
data_dates <-
as.Date(ncvar_get(data,varid = 'time') / 24,origin = '1949-12-01 00:00:00 GMT')
data_z <- ncvar_get(data,varid = 'count')
data_x <- ncvar_get(data,varid = 'jx')
data_y <- ncvar_get(data,varid = 'iy')
## Try to make a picture
image(data_x,data_y,(data_z[,1]))
## this works fine
## Try to make a picture using the lat longs
image(lon,lat,data_z[,1]))
## This does not work since both lon and lat are matrices. Converting them to vectors does not work either since they both end up being very big.
pts <- data.frame(cbind(
runif(10,min(lon),max(lon)),runif(10,min(lat),max(lat)),sample(seq(min(date),max(date),by="day"),10)
))
names(pts) <- c("lon","lat","date")
library(sp)
coordinates(pts) <- ~lon + lat
我对这一切都很陌生,所以不太确定我想做什么,但我现在的总体策略是:
- 提取每个点日期前 21 天我需要的切片。
- 将它们中的每一个转换为栅格
- 使用 raster::extract 从每个点的每个切片中提取 z 值 在我的点文件中使用 raster::extract
- 将这些点添加到我的主数据文件中,分为 21 列,代表感兴趣的日期前 21 个滞后天中的每一天。
我遇到的问题是
任何帮助将不胜感激。
我真的可以创建一个可重现的示例,因为我无法上传 .nc 文件。
谢谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)