Попытка интерполировать на сетку 0,1 градуса, используя растровые данные - PullRequest
0 голосов
/ 02 июля 2019

Попытка интерполировать данные в сетку с шагом в 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 не выполнена - "'экстент' не является слотом в классе" NULL ""

...