https://github.com/cran/fields
Revision 63d588c2cc1bacede5271cbb3a51a63c422060c9 authored by Doug Nychka on 04 September 2009, 00:00:00 UTC, committed by Gabor Csardi on 04 September 2009, 00:00:00 UTC
1 parent e6e2dec
Raw File
Tip revision: 63d588c2cc1bacede5271cbb3a51a63c422060c9 authored by Doug Nychka on 04 September 2009, 00:00:00 UTC
version 6.01
Tip revision: 63d588c
fields.convert.grid.R
# fields, Tools for spatial data
# Copyright 2004-2007, Institute for Mathematics Applied Geosciences
# University Corporation for Atmospheric Research
# Licensed under the GPL -- www.gpl.org/licenses/gpl.html
"fields.convert.grid" <- function(midpoint.grid) {
    # converts from midpoints of a grid to boundaries
    # x are midpoints of grid
    # this will handle unequally spaced points
    x <- sort(midpoint.grid)
    n <- length(x)
    # interior boundaries
    xi <- (x[2:n] + x[1:(n - 1)])/2
    # first and last.
    x1 <- x[1] - (x[2] - x[1])/2
    xnp1 <- x[n] + (x[n] - x[(n - 1)])/2
    #here you have it ...
    c(x1, xi, xnp1)
}
back to top