You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is a bug or a misunderstanding of the way the function works. In short, the issue is that when I specify layer as numeric in the extract function, values from the layer n-1 are extracted. Here's an example. I'm using Windows and version 1.7.46 of terra.
Thanks,
Ewan
library(terra)
r <- rast(ncol=4, nrow=4, nlyr=3, extent=ext(-2, 2, -2, 2))
Hi,
Not sure if this is a bug or a misunderstanding of the way the function works. In short, the issue is that when I specify layer as numeric in the extract function, values from the layer n-1 are extracted. Here's an example. I'm using Windows and version 1.7.46 of terra.
Thanks,
Ewan
library(terra)
r <- rast(ncol=4, nrow=4, nlyr=3, extent=ext(-2, 2, -2, 2))
values(r[[1]]) <- 1
values(r[[2]]) <- 2
values(r[[3]]) <- 3
xy <- data.frame(x=-1:1,y=-1:1)
extract(r, xy[,1:2]) # Behaves as expected
extract(r, xy[,1:2], ID=F, layer=c(1,1,1)) # Returns error
extract(r, xy[,1:2], ID=F, layer=c(2,2,2)) # Extracts from layer 1 not 2!
extract(r, xy[,1:2], ID=F, layer=c(3,3,3)) # Extracts from layer 2 not 3!
extract(r, xy[,1:2], ID=F, layer=c(4,4,4)) # Does not extract from layer 3!
The text was updated successfully, but these errors were encountered: