Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all.equal incorrect for multilayer SpatRasters #1236

Closed
see24 opened this issue Jul 17, 2023 · 0 comments
Closed

all.equal incorrect for multilayer SpatRasters #1236

see24 opened this issue Jul 17, 2023 · 0 comments

Comments

@see24
Copy link
Contributor

see24 commented Jul 17, 2023

terra::all.equal is giving incorrect results if rasters have multiple layers.

I will try a PR soon.

library(terra)
#> terra 1.7.41

x <- sqrt(1:100)
mat <- matrix(x, 10, 10)
r1 <- rast(nrows=10, ncols=10, xmin=0, vals = x)
r2 <- rast(nrows=10, ncols=10, xmin=0, vals = mat)

r3 <- c(r1, r2)
r4 <- c(r1, r2)

all.equal(r3, r4)
#> [1] "Mean relative difference: 0.3858482"

m <- minmax(r3 - r4)
all(abs(m) < 1e-7)
#> [1] TRUE

Created on 2023-07-17 with reprex v2.0.2

R version 4.3.1 (2023-06-16 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

other attached packages:
[1] terra_1.7-41

loaded via a namespace (and not attached):
[1] compiler_4.3.1   tools_4.3.1      Rcpp_1.0.11      codetools_0.2-19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant