Skip to content
Prev 10200 / 29559 Next

temporal interpolation with stackApply - seg fault

Hello again...

I've successfully applied the previously discussed function over a  
raster stack using calc.  However, the process seems to choke on large  
data sets.  It ran successfully on a stack with nlayers: 13, nrow:  
119, ncol 1048 but aborted with the stack below.

Could this be a memory issue?  I'm not sure if this is on my end, or  
something to do with the function.

Many thanks,
Mike


 > day
class       : RasterStack
nlayers     : 13
nrow        : 508
ncol        : 3825
ncell       : 1943100
projection  : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs  
+towgs84=0,0,0
min value   : 0 0 0 0 0 0 0 0 0 0 ...
max value   : 65535 65535 65535 65535 65535 65535 65535 65535 65535  
65535 ...
extent      : -175.4283, -100.0055, 59.98306, 70  (xmin, xmax, ymin,  
ymax)
resolution  : 0.01971838, 0.01971838  (x, y)

 > fill.LST <- function(x,na.rm = F){
+ x[x==0] <- NA
+ if(length(which(is.na(x)==F))>2){
+ fill <- approxfun(x, y=NULL, method='linear', rule=2)
+ rec <- which(is.na(x))
+ x[rec] <- fill(rec)
+ }
+ x <- (x*0.02)-273.15
+ return(x)
+ }

 > day.fill <- calc(day, fun=fill.LST, filename = "LST/ 
day.LST.h12v02.2005.tif")

  *** caught segfault ***
address 0x1020, cause 'memory not mapped'

Traceback:
  1: .Call("RGDAL_PutRasterData", raster, rasterData,  
as.integer(offset),     PACKAGE = "rgdal")
  2: putRasterData(raster at file@transient, t(v), band = i, c(0, 0))
  3: .writeGDALall(x, filename = filename, format = filetype, ...)
  4: .local(x, filename, ...)
  5: writeRaster(x, filename, ...)
  6: writeRaster(x, filename, ...)
  7: .local(x, fun, ...)
  8: calc(day, fun = fill.LST, filename = "LST/day.LST.h12v02.2005.tif")
  9: calc(day, fun = fill.LST, filename = "LST/day.LST.h12v02.2005.tif")

 > sessionInfo()
R version 2.10.0 (2009-10-26)
x86_64-redhat-linux-gnu

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] spatial_7.3-1 raster_1.7-5  rgdal_0.6-28  sp_0.9-66

loaded via a namespace (and not attached):
[1] grid_2.10.0     lattice_0.17-26
 >


Michael Loranty Ph.D.
Postdoctoral Fellow
The Woods Hole Research Center
149 Woods Hole Rd
Falmouth, MA 02540
508.444.1560
mloranty at whrc.org
On Dec 1, 2010, at 10:37 PM, Robert J. Hijmans wrote: