Description Usage Arguments Value Examples
Find column, row or other discrete divider reference in a grid, from its
co-ordinate. May also be used in the time dimension. Vectorised in
x
.
1 | cellref.loc(x, gcs, rev = FALSE)
|
x |
numeric |
gcs |
numeric |
rev |
logical |
An integer vector of the same length as x
, showing which grid cell
reference the values of x
are found in. NA
shows that values
of x
are outside the grid boundaries.
Values of x
that are exactly on the grid lines are assigned to the
smaller reference (or greater if rev = TRUE
, as a side effect of
rev
).
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 29 30 31 | # some of these values may be outside the grid boundary
x <- sample(seq(0, 11, .1), 20)
# irregular grids are supported, but gcs must be in ascending order
gcs <- sort(sample(seq(0, 10, .5), 11))
cellref.loc(x, gcs)
cellref.loc(x, gcs, TRUE)
# for MODFLOW models:
library("RNetCDF")
mfdata <- open.nc(system.file("rflow_mf_demo.nc", package = "Rflow"))
#
# - example column reference
gccs <- c(var.get.nc(mfdata, "gccs") +
att.get.nc(mfdata, "NC_GLOBAL", "origin-x"))
(C <- cellref.loc(625, gccs))
#
# - example row reference
# -- rows are numbered in order of decreasing y, so put rev = TRUE
grcs <- c(var.get.nc(mfdata, "grcs") +
att.get.nc(mfdata, "NC_GLOBAL", "origin-y"))
(R <- cellref.loc(825, grcs, TRUE))
#
# - example layer reference
# -- layer divides are in descending order, so reverse the layer
# divides and also use rev = TRUE
ldivs.cr <- c(var.get.nc(mfdata, "elev", c(C, R, NA), c(1L, 1L, NA)))
(L <- cellref.loc(25, rev(ldivs.cr), TRUE))
#
# - example time step reference
(ts <- cellref.loc(1500, mftstime(mfdata)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.