We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi @rhijmans
terra::adjacent does not include the focal cell in the returned matrix. This is true when pairs is also TRUE. See raster::adjacent for comparison
library(raster) r <- raster::raster(nrows=10, ncols=10) raster::adjacent(r, cells=c(1, 55), directions=8, pairs=TRUE) raster::adjacent(r, cells=c(1, 55), directions=8, pairs=TRUE, include = TRUE) library(terra) r <- terra::rast(nrows=10, ncols=10) terra::adjacent(r, cells=c(1, 55), directions=8, pairs = TRUE) terra::adjacent(r, cells=c(1, 55), directions=8, pairs = TRUE, include = TRUE)
The text was updated successfully, but these errors were encountered:
a53acf9
Thanks for reporting this. We already had
library(terra) #terra 1.6.20 r <- rast(nrows=10, ncols=10) adjacent(r, cells=55, directions=4, pairs=F, include=F) # [,1] [,2] [,3] [,4] #54 45 54 56 65 adjacent(r, cells=55, directions=4, pairs=F, include=T) # [,1] [,2] [,3] [,4] [,5] #[1,] 55 45 54 56 65 adjacent(r, cells=55, directions=4, pairs=T, include=F) # from to #[1,] 55 45 #[2,] 55 54 #[3,] 55 56 #[4,] 55 65
And now this one also works as expected:
adjacent(r, cells=55, directions=4, pairs=T, include=T) # from to #[1,] 55 55 #[2,] 55 45 #[3,] 55 54 #[4,] 55 56 #[5,] 55 65
Sorry, something went wrong.
No branches or pull requests
Hi @rhijmans
terra::adjacent does not include the focal cell in the returned matrix. This is true when pairs is also TRUE. See raster::adjacent for comparison
The text was updated successfully, but these errors were encountered: