[R-sig-Geo] How to properly use rsaga.close.gaps()

piero campa piero.campa at gmail.com
Sun May 20 13:06:23 CEST 2012


Dear list,

after reading through "Spatio-temporal prediction of daily temperatures
using time-series of MODIS LST images" (Hengl et al.,
http://dx.doi.org/10.1007/s00704-011-0464-2), I wanted to try out these SAGA
*grid_tools* modules to fill the gaps in my MODIS AOT datasets.

I tried to follow what is done in the related script
(http://spatial-analyst.net/book/HRtemp.R) but I think I am missing
something, since my filled output is just identical to my input grid.

I will report my steps by means of the usual /meuse/ dataset:

data(meuse.grid)

coordinates(meuse.grid) <- ~x+y
gridded(meuse.grid) <- TRUE
fullgrid(meuse.grid) <- TRUE

# Create some hole
meuse.grid$dist[meuse.grid$dist > .3] <- NA

# Input File for SAGA
writeGDAL(meuse.grid["dist"], "dist.sdat", "SAGA")

# Run SAGA utility
rsaga.get.usage(lib="grid_tools", module=7)
rsaga.geoprocessor(lib="grid_tools", module=7, param=list(INPUT="dist.sgrd",
RESULT="sp_dist.sgrd"))
# = rsaga.close.gaps("dist.sgrd", "sp_dist.sgrd")  ?

# Import SAGA output
meuse.grid$sp_dist <- readGDAL("sp_dist.sdat")$band1

# The new gap-filled grid is indentical to the input:
spplot(meuse.grid, zcol=c("dist", "sp_dist"))


In his script, Tomislav also specified an input mask grid:
meuse.grid$mask <- as.integer(ifelse(is.na(meuse.grid$dist), NA, 1)) # or
!isna() ?
writeGDAL(meuse.grid["mask"], "mask.sdat", "SAGA")
rsaga.geoprocessor(lib="grid_tools", module=7, param=list(INPUT="dist.sgrd",
MASK="mask.sgrd",  RESULT="sp_dist.sgrd"))

I tried to mask either the is.na() and !is.na() pixels, but still no
interpolation takes place.
Any help?

Thanks.

  Piero

--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/How-to-properly-use-rsaga-close-gaps-tp7567747.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list