Learn R Programming

tidyterra (version 1.3.0)

is_regular_grid: Check whether x and y positions form a regular grid

Description

Assess whether the x and y coordinates of an object form a regular grid. This function is called for its side effects.

This function is called internally by as_spatraster().

Usage

is_regular_grid(xy, digits = 6)

Value

Nothing, invisibly, if the coordinates form a regular grid. Otherwise, an error.

Arguments

xy

A matrix, data frame or tibble with at least two columns representing x and y coordinates.

digits

Integer to set the precision for detecting whether points are on a regular grid (a low number of digits is a low precision).

See Also

as_spatraster().

Examples

Run this code

p <- matrix(1:90, nrow = 45, ncol = 2)

is_regular_grid(p)

# Jitter locations.
set.seed(1234)
jitter <- runif(length(p)) / 10e4
p_jitter <- p + jitter

# Adjust digits.
is_regular_grid(p_jitter, digits = 4)

Run the code above in your browser using DataLab