Learn R Programming

tidyterra (version 0.7.2)

is_regular_grid: Check if x and y positions conforms a regular grid

Description

Assess if the coordinates x,y of an object conforms a regular grid. This function is called by its side effects.

This function is internally called by as_spatraster().

Usage

is_regular_grid(xy, digits = 6)

Value

invisible() if is regular or an error message otherwise

Arguments

xy

A matrix, data frame or tibble of 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()

Other helpers: compare_spatrasters(), is_grouped_spatvector(), pull_crs()

Examples

Run this code

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

is_regular_grid(p)


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

# Need to adjust digits
is_regular_grid(p_jitter, digits = 4)

Run the code above in your browser using DataLab