Hi,
I am trying to use the approxfunction to interpolate monthly time series data on air temperature (ts.tair), soil temperature (ts.tsoil), incoming solar radiation (ts.srad), soil moisture (ts.moist1) and (ts.moist2) from 2000 to 2019. There are 4,210,275 spatial points on climate data in total.
class(ts.tair)
[1] "matrix"
dim(ts.tair)
[1] 4210275 240
class(ERA.dates)
[1] "Date"
head(ERA.dates)
[1] "2000-01-15" "2000-02-15" "2000-03-15" "2000-04-15" "2000-05-15" "2000-06-15"
dim(ERA.dates)
[1] 240
range(ERA.dates)
[1] "2000-01-15" "2019-12-15"
When I run the approxfun, I get the following error;
af.tair = approxfun(ERA.dates,ts.tair[1,])
af.tsoil = approxfun(ERA.dates,ts.tsoil[1,])
af.srad = approxfun(ERA.dates,ts.srad[1,])
af.moist1 = approxfun(ERA.dates,ts.moist1[1,])
af.moist2 = approxfun(ERA.dates,ts.moist2[1,])
Error in approxfun(ERA.dates, ts.tair[1, ]) :
need at least two non-NA values to interpolate
af.tsoil = approxfun(ERA.dates,ts.tsoil[1,])
Error in approxfun(ERA.dates, ts.tsoil[1, ]) :
need at least two non-NA values to interpolate
af.srad = approxfun(ERA.dates,ts.srad[1,])
Error in approxfun(ERA.dates, ts.srad[1, ]) :
need at least two non-NA values to interpolate
af.moist1 = approxfun(ERA.dates,ts.moist1[1,])
Error in approxfun(ERA.dates, ts.moist1[1, ]) :
need at least two non-NA values to interpolate
af.moist2 = approxfun(ERA.dates,ts.moist2[1,])
Error in approxfun(ERA.dates, ts.moist2[1, ]) :
need at least two non-NA values to interpolate
Your assistance will be highly appreciated
Regards
Edward