Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

resample

Resampling of data involving a trigrid or a hexagrid object.


Description

The function is used to resolve and resample data stored in RasterLayers and facelayers so they can be fitted to and can be plotted by using trigrid or hexagrid objects.

The function applies different resampling algorithms. Currently there are only two implemented methods, one for upscaling and one for downscaling. The downscaling method "average" will tabluate all face centers from the high resolution grid that fall on a coarse resolution cell and average them. The upscaling method "ebaa" (edge breakpoint area approximation) will estimate the areas covered by the high resolution cells using the number of edge breakpoints.

Usage

resample

## S4 method for signature 'Raster,trigrid'
resample(x, y, method = "ngb", na.rm = TRUE)

## S4 method for signature 'facelayer,trigrid'
resample(x, y, method = NULL, res = 5)

Arguments

x

(RasterLayer, facelayer) Object to resample.

y

(hexagrid or trigrid) Object describing the target structure.

method

(character) The name of the algorithm used for resampling.

na.rm

(logical) If a face contains a missing value, should its value be NA as well (FALSE) or calculate the mean anyway (TRUE).

res

(numeric) Value indicating the precision of area estimation during the upscaling (facelayer-method). In case the "ebaa" method is chosen, the variable indicate the number of breaking points on an edge.

Format

An object of class standardGeneric of length 1.

Details

This method is necessary to utilize rasterized data in the icosa package. The only method currently implemented upscales the raster data and then resolves the values to the trigrid or hexagrid values, using averages. In the case of resampling RasterLayers, the method argument will be passed to the resample function.

Value

A named numeric vector.

Examples

# create a grid
g <- trigrid(c(4,4))
# create a data layer
fl <- facelayer(g)
fl@values<-rnorm(length(fl))
# target structure
h <- trigrid(4)
# resampling
res <- resample(fl, h)
fl2<-facelayer(h)
fl2@values[] <- res

icosa

Global Triangular and Penta-Hexagonal Grids Based on Tessellated Icosahedra

v0.10.1
GPL-3
Authors
Adam T. Kocsis [aut, cre]
Initial release
2021-01-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.