hydrokrige: Krige for Hydrological Time Series In hydroTSM: Time Series Management, Analysis and Interpolation for Hydrological Modelling

Description

Automatic interpolation for hydrological ts, with optional plot (wrapper to some functions of the gstat and automap packages)

Originally it was thought as a way to make easier the computation of average precipitation over subcatchments (given as input in a shapefile map), based on values measured at several gauging stations, but nowadays it can also be used for interpolating any variable over a grid given by a raster map.

Available algorithms: inverse distance weighted (IDW), ordinary kriging (OK) and kriging with external drift (KED)

The (Block) Inverse Distance Weighted (IDW) interpolation is a wrapper to the idw function of the gstat package (so, it requires the gstat package).

The automatic kriging (OK or KED) is a wrapper to the autoKrige function of the automap package (so, it requires the automap and gstat packages), which automatically selects the best variogram model from four different ones: spherical, exponential, gaussian and Matern with M. Stein's parameterization (for more details, see autoKrige)

Usage

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 hydrokrige(x.ts, x.gis, ...) ## Default S3 method: hydrokrige(x.ts, x.gis, X= "x", Y= "y", sname, bname, elevation, predictors, catchment.name = "all", type="cells", formula, subcatchments, IDvar = NULL, p4s=CRS(as.character(NA)), cell.size = 1000, grid.type = "regular", nmin = 0, nmax = Inf, maxdist = Inf, ColorRamp = "PCPAnomaly", plot = TRUE, col.nintv = 10, col.at = "auto", main, stations.plot = FALSE, stations.offset, arrow.plot = FALSE, arrow.offset, arrow.scale, scalebar.plot = FALSE, sb.offset, sb.scale, verbose = TRUE, allNA.action="error", ...) ## S3 method for class 'data.frame' hydrokrige(x.ts, x.gis, X= "x", Y= "y", sname, bname, elevation, predictors, catchment.name = "all", type = "block", formula, subcatchments, IDvar= NULL, p4s=CRS(as.character(NA)), cell.size = 1000, grid.type = "regular", nmin = 0, nmax = Inf, maxdist = Inf, ColorRamp = "PCPAnomaly", plot = FALSE, col.nintv = 10, col.at = "auto", main, stations.plot = FALSE, stations.offset, arrow.plot = FALSE, arrow.offset, arrow.scale, scalebar.plot = FALSE, sb.offset, sb.scale, verbose = TRUE, allNA.action="error", dates=1, from, to, write2disk = TRUE, out.fmt= "csv2", fname = paste(ColorRamp, "by_Subcatch.csv", sep = ""), ...)

Details

The type of interpolation (IDW, OK, KED) is obtained from the argument formula:

-) When formula is missing, an IDW interpolation, by calling the idw function in the gstat package, with formula = value~1.
-) When formula = value~1, an OK interpolation, by calling the autoKrige function, with formula = value~1.
-) When formula = value~pred1 + pred2 + ..., a KED interpolation, by calling the autoKrige function, with the formula specified by the user.

When type is block or both, a block interpolation is carried out for each subcatchment defined by subcatchments, so far, computing the average value over all the cells belonging to each subcatchment.

The automatic kriging is carried out by using a variogram generated automatically with the autofitVariogram function of the automap package.

Value

 Cells When type is cells, the output object is a SpatialPixelsDataFrame-class, which slot 'data' has two variables: 'var1.pred' and 'var1.var' with the predictions and its variances, respectively

 Block When type is block, the output object is a SpatialPolygonsDataFrame-class, which slot 'data' has four variables: 'x', 'y' with the easting and northing coordinate of the centroid of the catchments specified by subcatchments , and 'var1.pred' and 'var1.var' with the predictions and its variances, respectively

 list(Cells, Block) When type is both, the resulting object is a list, with the two elements previously described.

Note

IMPORTANT: It is you responsibility to check the validity of the fitted variogram !!.

Author(s)

Mauricio Zambrano-Bigiarini, mzb.devel@gmail

References

N.A.C. Cressie, 1993, Statistics for Spatial Data, Wiley.

Applied Spatial Data Analysis with R. Series: Use R. Bivand, Roger S., Pebesma, Edzer J., Gomez-Rubio, Virgilio. 2008. ISBN: 978-0-387-78170-9

Pebesma, E.J., 2004. Multivariable geostatistics in S: the gstat package. Computers & Geosciences, 30: 683-691