to_raster: Rasterize a Scattered 2D or 3D Signal

View source: R/signal2.R

to_rasterR Documentation

Rasterize a Scattered 2D or 3D Signal

Description

Estimate the raster dimensions of a scattered 2D or 3D signal based on its pixel coordinates.

Usage

# Rasterize a 2D signal
to_raster(x, y, vals)

# Rasterize a 3D signal
to_raster3(x, y, z, vals)

# Check if coordinates are gridded
is_gridded(x, tol = sqrt(.Machine$double.eps))

Arguments

x, y, z

The coordinates of the data to be rasterized. For is_gridded(), a numeric matrix or data frame where each column gives the pixel coordinates for a different dimension.

vals

The data values to be rasterized.

tol

The tolerance allowed when estimating the resolution. Noise in the sampling rate will be allowed up to this amount when determining if the data is approximately gridded or not.

Details

This is meant to be a more efficient version of approx2() when the data is already (approximately) gridded. Otherwise, approx2() is used.

Value

A numeric vector giving the estimated raster dimensions.

Author(s)

Kylie A. Bemis

See Also

approx2

Examples

# create an image
set.seed(1)
i <- seq(-4, 4, length.out=12)
j <- seq(1, 3, length.out=9)
co <- expand.grid(x=i, y=j)
z <- matrix(atan(co$x / co$y), nrow=12, ncol=9)
vals <- 10 * (z - min(z)) / diff(range(z))

# scatter coordinates and flatten image
d <- expand.grid(x=jitter(1:12), y=jitter(1:9))
d$vals <- as.vector(z)

# rasterize
to_raster(d$x, d$y, d$vals)

kuwisdelu/matter documentation built on Oct. 19, 2024, 10:31 a.m.