尝试使用栅格数据插值到0.1度网格

时间:2019-07-01 22:57:44

标签: r hdf rasterize

尝试将数据插值到0.1度网格。文件是hdf,分辨率为2160 x 4320。插值后尝试重新网格化数据,以便可以查询文件以获取单独的地理坐标。

这是我的代码:

library(OceanData)

# Station
loc <- matrix(c("AC1", 29.47455, -86.9587,
                "NT800", 28.056, -85.9335,
                "NT1000", 28.00399, -85.9991,
                "PCB06", 28.99451, -87.4574,
                "PM", 28.53043, -88.0709,
                "S35", 29.33515, -87.0464,
                "S36", 28.91851, -87.6722,
                "S42", 28.2528, -86.4216,
                "Seep A", 29.04303, -87.2825,
                "XC1", 29.24821, -87.7319,
                "XC2", 29.12092, -87.8655,
                "XC3", 28.97617, -87.8683,
                "XC4", 28.6365, -87.8685), nrow=13, ncol=3, byrow=T)
loc <- cbind((loc[,1]), as.data.frame(cbind(as.numeric(loc[,2]), as.numeric(loc[,3]))))
names(loc) <- c("Name", "Latitude", "Longitude")
coordinates(loc) <- c("Longitude", "Latitude")
projection(loc) <- "+proj=longlat +datum=WGS84"

# spatial extent template
z <- raster("etopo1.tif")
z <- calc(z, function(x)-x)

#### Get chl & vgpm from 2018-01 to 2018-03 (using VIIRS) 

# Create a folder to output raster bricks 
folder <- "Ocean_Productivity"
dir.create(folder)

# Year and day of year by month from 2018-01-01 to 2018-03-01
viirs <- Year_Day("2018-06-01", "2018-08-01", by="month") # SEAWiFS time series

# URLs for each variable
# The URL path may change depending on the NASA Ocean Color reprocessing version
# Check http://www.science.oregonstate.edu/ocean.productivity/ before using the following example

# Chlorophyll concentration
chl <- paste("http://orca.science.oregonstate.edu/data/2x4/monthly/chl.viirs.r2018/hdf/chl", viirs, "hdf.gz", sep=".")

# Vertical General Production model
vgpm <- paste("http://orca.science.oregonstate.edu/data/2x4/monthly/vgpm.r2018.v.chl.v.sst/hdf/vgpm", viirs, "hdf.gz", sep=".")

url_list <- list(chl, vgpm)
names(url_list) <- c("chl", "vgpm")

# Download the entire time series 
library(foreach)
library(doSNOW)

cl<-makeCluster(4) # change 4 to your number of CPU cores
registerDoSNOW(cl) # register the SNOW parallel backend with the foreach package
foreach(i=1:3, .packages=c("OceanData")) %dopar% Get_all_Ocean_Prod(url_list, ts=i, x=z, outdir=folder)
stopCluster(cl) # stop a SNOW cluster

这是我收到的错误消息

  

Get_all_Ocean_Prod中的错误(url_list,ts = i,x = z,outdir =文件夹)   :任务3失败-“'extent'不是类“ NULL”中的插槽“

0 个答案:

没有答案