pick.from.points {RSAGA} | R Documentation |
These functions pick (i.e. interpolate without worrying too
much about theory) values of a spatial variables from a data stored in a
data.frame, a point shapefile, or an ASCII or SAGA grid, using nearest neighbor
or kriging interpolation. pick.from.points
is the core function that
is called by the different wrappers.
pick.from.points(data, src, pick, method = c("nearest.neighbour", "krige"), set.na = FALSE, radius = 200, nmin = 0, nmax = 100, sill = 1, range = radius, nugget = 0, model = vgm(sill - nugget, "Sph", range = range, nugget = nugget), log = rep(FALSE, length(pick)), X.name = "x", Y.name = "y", cbind = TRUE) pick.from.shapefile(data, shapefile, X.name = "x", Y.name = "y", ...) pick.from.ascii.grid(data, file, path, varname, prefix, method = c("nearest.neighbour", "krige"), nodata.values = c(-9999, -99999), at.once, quiet = TRUE, X.name = "x", Y.name = "y", nlines = Inf, cbind = TRUE, range, radius, na.strings = "NA", ...) pick.from.saga.grid(data, filename, path, varname, prec = 7, show.output.on.console = FALSE, env = rsaga.env(), ...)
data |
data.frame giving the coordinates (in columns specified by
X.name, Y.name ) of point locations at which to interpolate
the specified variables or grid values |
src, shapefile |
data.frame or point shapefile |
pick |
variables to be picked (interpolated) from src ;
if missing, use all available variables, except those specified
by X.name and Y.name |
method |
interpolation method to be used; uses a partial match to
the alternatives "nearest.neighbor" (currently the default)
and "krige" |
set.na |
logical: if a column with a name specified in pick
already exists in data , how should it be dealt with?
set.na=FALSE (default) only overwrites existing data if the
interpolator yields a non-NA result;
set.na=TRUE passes NA values returned by the interpolator
on to the results data.frame |
radius |
numeric value specifying the radius of the local neighborhood
to be used for interpolation; defaults to 200 map units (presumably meters),
or, in the functions for grid files, 2.5*cellsize . |
nmin, nmax |
numeric, for method="krige" only:
see krige function in package gstat |
sill |
numeric, for method="krige" only: the overall sill
parameter to be used for the variogram |
range |
numeric, for method="krige" only: the variogram range |
nugget |
numeric, for method="krige" only: the nugget effect |
model |
for method="krige" only:
the variogram model to be used for interpolation;
defaults to a spherical variogram with parameters specified by
the range , sill , and nugget arguments;
see vgm in package gstat for details |
log |
logical vector, specifying for each variable in pick
if interpolation should take place on the logarithmic scale
(default: FALSE ) |
X.name, Y.name |
names of the variables containing the x and y coordinates |
cbind |
logical: shoud the new variables be added to the input data.frame
(cbind=TRUE , the default), or should they be returned as a separate
vector or data.frame? cbind=FALSE |
file |
file name (relative to path , default file extension .asc )
of an ASCII grid from which to pick a variable, or an open connection
to such a file |
path |
optional path to file |
varname |
character string: a variable name for the variable interpolated from
grid file file in pick.from.*.grid ; if missing, variable name
will be determined from file name by a call to
create.variable.name |
prefix |
an optional prefix to be added to the varname |
nodata.values |
numeric vector specifying grid values that should
be converted to NA ; in addition to the values specified here,
the nodata value given in the input grid's header will be used |
at.once |
logical: should the grid be read as a whole or line by line?
at.once=FALSE is useful for processing large grids that do not
fit into memory; the argument is currently by default FALSE
for method="nearest.neighbour" , and it currently MUST be
TRUE for all other methods (in these cases, TRUE is
the default value); piecewise processing with at.once=FALSE
is always faster than processing the whole grid at.once |
quiet |
logical: provide information on the progress of grid processing
on screen? (only relevant if at.once=FALSE and
method="nearest.neighbour" ) |
nlines |
numeric: stop after processing nlines lines of the
input grid; useful for testing purposes |
filename |
character: name of a SAGA grid file, default extension .sgrd |
prec |
numeric, specifying the number of digits to be used in converting
a SAGA grid to an ASCII grid in pick.from.saga.grid |
na.strings |
passed on to scan |
env |
list: RSAGA geoprocessing environment created by
rsaga.env |
show.output.on.console |
a logical (default: FALSE ),
indicates whether to capture
the output of the command and show it on the R console
(see system , rsaga.geoprocessor ). |
... |
arguments to be passed to pick.from.points |
If cbind=TRUE
, columns with the new, interpolated variables
are added to the input data.frame data
.
If cbind=FALSE
, a data.frame only containing the new variables
is returned (possibly coerced to a vector if only one variable is processed).
method="krige"
requires the gstat package.
pick.from.shapefile
requires the shapefiles package.
The nearest neighbour interpolation currently randomly breaks ties if
pick.from.points
is used, and in a deterministic fashion (rounding
towards greater grid indices, i.e. toward south and east) in the grid
functions.
Alexander Brenning
~put references to the literature/web site here ~
grid.to.xyz
,
read.ascii.grid
, write.ascii.grid
# use the meuse data for some tests: require(gstat) data(meuse) data(meuse.grid) meuse.nn = pick.from.points(data=meuse.grid, src=meuse, pick=c("cadmium","copper","elev"), method="nearest.neighbour") meuse.kr = pick.from.points(data=meuse.grid, src=meuse, pick=c("cadmium","copper","elev"), method="krige", radius=100) # it does make a difference: plot(meuse.kr$cadmium,meuse.nn$cadmium) plot(meuse.kr$copper,meuse.nn$copper) plot(meuse.kr$elev,meuse.nn$elev)