Description Usage Arguments Value Note Author(s) Examples
This function use an inverse distance weighted interpolation to estimate climate values in areas previously emerged that are now under the water. It use the values in the closest pixels to estimate the values in pixels specified by a shoreline raster.
1 | interpolateCoastal(raster, shore)
|
raster |
Raster object, with the variable to be interpolated |
shore |
Raster object with values 1 to areas emerged and NA otherwise. This raster should have the same extent and resolution as the climatic raster. |
The output is a new raster with the same extent and resolution than the input raster (raster). Pixel with value 1 in shore that have values already in raster are unchanged, whereas those whitout value in raster are interpolated by inverse distance weighted interpolation.
Interpolation method is in gstat package, with nmax=7 and idp=0.5.
Diego Nieto Lugilde
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(raster, shore)
{
xy <- data.frame(xyFromCell(raster, 1:ncell(raster)))
v <- getValues(raster)
dat <- data.frame(xy, v)
dat <- dat[complete.cases(dat),]
# mg <- Tps(x=xy, Y=v) Esta funcion peta
mg <- gstat(formula=v~1, locations=~x+y, data=dat, nmax=7, set=list(idp = .5))
p <- raster(raster)
z <- interpolate(p, mg)
nz <- z * shore
nnz <- cover(raster, nz)
return(nnz)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.