ropensci / slopes

Package to calculate slopes of roads, rivers and trajectories
https://docs.ropensci.org/slopes/
GNU General Public License v3.0
70 stars 6 forks source link

slope_raster() error with terra rast object #48

Closed lauren-obrien closed 1 year ago

lauren-obrien commented 1 year ago

Hi, this package is so useful! Many thanks.

Unfortunately, there seems to be a new error in slope_raster() when using a terra::rast() object as DEM, see below (example code is from terra::extract() help page, with a couple of mods):

library(sf)
library(terra)    # 1.6-47
library(slopes)

r <-rast(ncols=5, nrows=5, xmin=0, xmax=5, ymin=0, ymax=5)
values(r) <- 1:25
xy <- rbind(c(0.5,0.5), c(2.5,2.5))
p <- vect(xy, crs="+proj=longlat +datum=WGS84", typ = 'lines')
p <- st_as_sf(p)

slope_raster(p, r)
# Error in .local(x, y, ...) : unused argument (method = "bilinear")

slope_raster(p, raster::raster(r))
# runs ok, with appropriate warnings about large distances

This actually looks like a regression in terra, see Issue 46 and commit https://github.com/rspatial/terra/commit/81bfb0a8a9cb1930995e902fabcf6d2219202ded

Robinlovelace commented 1 year ago

Thanks for the bug report and very useful reproducible example. Motivation to finally get this on CRAN #45! I guess this issue arose after the latest version of terra on 2nd December, right? https://cran.r-project.org/package=terra

lauren-obrien commented 1 year ago

I assume so - sorry, only used this package for the first time today and have been using terra only intermittently of late

Robinlovelace commented 1 year ago

Fixed upstream now: https://github.com/rspatial/terra/issues/956

maelle commented 1 year ago

@Robinlovelace I think the pkgdown building is failing due to this same problem. The vignette benchmark.Rmd can't be knit. Should there be a Remotes field in DESCRIPTION until terra is re-released?

Robinlovelace commented 1 year ago

@Robinlovelace I think the pkgdown building is failing due to this same problem. The vignette benchmark.Rmd can't be knit. Should there be a Remotes field in DESCRIPTION until terra is re-released?

Probably. Will check with the author of terra on likely ETA for release (talking of which #45 still needs to be on CRAN, any help with that from rOpenSci v. welcome).

@rspatial when is the next version of terra likely to be released?

Many thanks.

Robinlovelace commented 1 year ago

And @rhijmans, hopefully you get this notification. Thanks!

rhijmans commented 1 year ago

I can send it to CRAN sometime this week.

Robinlovelace commented 1 year ago

I can send it to CRAN sometime this week.

Fantastic, many thanks Robert.