【发布时间】:2020-03-10 18:36:16
【问题描述】:
编辑
我已经编辑了我的问题,因为我取得了一些进展。
我正在尝试处理本网站中的伯克利地球数据。 http://berkeleyearth.org/data/。获取样本数据:
向下滚动到:
Daily Land(实验性;1880 - 最近)> 平均高温 (TMAX) > 1º x 1º 纬度-经度网格(每十年 200-450 MB)> 1990-1999
此 netCDF 文件描述了 1990-1999 年间每一天的平均 tmax 和异常值,作为经度和纬度的函数。我还有一组不同的纬度,我想提取每日平均 tmax 和异常数据。这就是我要做的事情。
dat <- structure(list(locatioID = paste0('ID', 1:16), lon = c(73.73, 86, 73.45, 86.41, 85.36, 81.95, 82.57, 75.66, 82.03, 81.73, 85.66, 85.31, 81.03, 81.70, 87.03, 73.38), lat = c(24.59, 20.08, 22.61, 23.33, 23.99, 19.09, 18.85, 15.25, 26.78, 16.63, 25.98, 23.28, 24.5, 21.23, 25.08, 21.11)),
row.names = c(1L, 3L, 5L, 8L, 11L, 14L, 17L, 18L, 19L, 21L,
23L, 26L, 29L, 32L, 33L, 35L), class = "data.frame")
xy <- dat[,2:3]
spts <- SpatialPoints(xy, proj4string=CRS("+proj=longlat +datum=WGS84"))
# read the netcdf file
ncname <- file.path(dirList$inputDir, 'climate','tmax','Complete_TMAX_Daily_LatLong1_1990.nc')
ncin <- nc_open(ncname)
print(ncin)
# first I find the length of the datapoints in the netcdf
lengthvar <- ncin$var[[1]][['varsize']]
# there are 3652 days in the netcdf
# define the variables I need
dname1 <- 'temperature' # anomaly
dname2 <- 'climatology' # climatology
# load as a stack separately for climatology and anomaly
climtest <- brick(ncname, varname = 'climatology')
anotest <- brick(ncname, varname = 'temperature')
# Now iterate through each day and extract the climatology and anomaly
for(i in 1:lengthvar){
tempClim <- climtest[[i]]
tempAno <- anotest[[i]]
# Extract data by spatial point
temp2 <- extract(tempClim, spts)
temp2 <- extract(tempAno, spts)
# Error in if (x@file@nodatavalue < 0) { : missing value where TRUE/FALSE needed
}
我不确定这个错误是什么意思,以及我在这里做错了什么导致了这个错误。
【问题讨论】:
-
你能给出更精确的数据链接吗?这个? berkeleyearth.lbl.gov/auto/Global/Gridded/… - 它很大,我宁愿第一次做对,也不愿浪费带宽。
-
是的,就是链接。