Skip to contents

Using spatial interpolation this function transforms a geofield to another geometry.

Usage

regrid(infield, newdomain=.Last.domain(),
       method="bilin", mask=NULL, newmask=NULL, weights=NULL)
regrid.init(olddomain, newdomain=.Last.domain(),
            method="bilin", mask=NULL, newmask=NULL)

Arguments

infield

A geofield object.

olddomain

A geodomain object. It may aso be a geofield, but only the domain attribute is used for initialising the interpolation.

newdomain

A geodomain or a geofield. In the second case, the new domain attribute is taken from this second field. The default value is the .Last.domain(), the last domain that has been plotted.

#

...

Options for point.interp.

method

The interpolation method can be bilinear ("bilin"), bicubic ("bicub") or nearest neighbour ("n" or "c"). Additionally, there are two methods for upscaling: "mean" and "median" (the latter is not yet implemented).

mask, newmask

A mask (grid of same dimension as infield), points with value 0 (or FALSE) are not used for interpolation. You must provide it for both the old and new grid.

weights

Output from regrid.init. By providing such weights, you can save a lot of time if many fields need interpolation.

Value

A geofield object.

Details

This routine uses interpolation to transform the data to a new domain (for instance, different grid resolution, different projection...).

If you use Land/Sea masks, it is possible that a "land" point in the new domain lies between 4 "sea" points of the original domain. In that case, the mask is not applied (the interpolation uses force=FALSE).

Examples

if (FALSE) {
regrid(field1,field2) # this will output the data of field1 interpolated to the grid of field 2

iview(field1)
cview(regrid(field2),add=TRUE) # add contours of field2, interpolated to the last plotted grid, which is field1.
}