rspatial / terra

R package for spatial data handling https://rspatial.github.io/terra/reference/terra-package.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flip - incorrect start and/or nrows value

ECarnell opened this issue · comments

Hello,

I'm trying to use terra::flip on a spatRaster but keep getting the error "incorrect start and/or nrows value"

Here's a minimal example:

r <- rast(ext = ext(c(xmin = -30, xmax = 50, ymin = 30, ymax = 75)),
          res = 0.01, crs = "EPSG:4326")

r[] <- 1:ncell(r)

flip(r,"vertical")

Setting the resolution to 0.1 works, so perhaps due to number of cells?

Can you please follow the instructions and show the version of "terra" that you are using; as returned by library(terra)? I am not a stickler for rules, but my guess is that you are not using the current version.

I can reproduce this in terra 1.7.78 and setting RAM limit.

library("terra")
#> terra 1.7.78
terraOptions(memmax = 1.3)

r <- rast(ext = ext(c(xmin = -30, xmax = 50, ymin = 30, ymax = 75)),
          res = 0.01, crs = "EPSG:4326")
r[] <- 1:ncell(r)
flip(r,"vertical")
#> ===========================Error: [flip] incorrect start and/or nrows value

Thanks @ECarnell for reporting this persistent bug, and @kadyb for making it reproducible for me. I believe it has been fixed now.

Thanks Robert,

I've just installed the dev version and unfortunately still get the same error?

install.packages("terra", repos = "https://rspatial.r-universe.dev")
require(terra)
#> Loading required package: terra
#> terra 1.7.79
r <- rast(ext = ext(c(xmin = -30, xmax = 50, ymin = 30, ymax = 75)),
          res = 0.01, crs = "EPSG:4326")

r[] <- 1:ncell(r)

flip(r,"vertical")
#> Error: [flip] incorrect start and/or nrows value

RUniverse has not built the new version yet. You can find out about the status here:
https://rspatial.r-universe.dev/terra

Currently it says:

Last updated 22 hours ago from: b42fcd708fcd0d2e6dccc6036c0e9619693d5be7

I just triggered a run of the build process, so hopefully it will be available within 30 minutes from now.