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

Transition to terra #18

Closed
see24 opened this issue Mar 23, 2022 · 5 comments · Fixed by #19
Closed

Transition to terra #18

see24 opened this issue Mar 23, 2022 · 5 comments · Fixed by #19

Comments

@see24
Copy link
Member

see24 commented Mar 23, 2022

Start a new branch to work on using terra instead of raster. Continue supporting raster inputs though. Look into whether terra can do the things we currently do with stars to see if we can remove that dependency. I will document any challenges that come up here as a reference for repeating the process in other packages

The terra website has a table showing new function names and raster equivalents and highlights differences in behaviour https://rspatial.github.io/terra/reference/terra-package.html#xxv-new-method-names-1

@see24
Copy link
Member Author

see24 commented Mar 23, 2022

Functions that seem different but not included in table above

raster terra behaviour change
clump patches raster used 0 and NA as background default in terra is just NA
unique unique Now returns a data.frame (in both raster and terra) used to be a vector?
rasterToPoints as.points No longer has option to use a function
as.matrix as.matrix Returns 1 column per layer unless wide = TRUE

@see24
Copy link
Member Author

see24 commented Mar 25, 2022

Note that terra::vect which converts sf objects to SpatVector will drop additional geometry types if the input is a geometry collection. See terra issue

@see24
Copy link
Member Author

see24 commented May 20, 2022

Needed to keep sp and raster as dependencies in the package in order to deal with sp and raster inputs. Also kept the demoScen rasters as Raster* objects because terra SpatRasters cannot be stored in .rds files without first wrapping them which would then need to be unwrapped before using

@see24
Copy link
Member Author

see24 commented Jun 3, 2022

Doing something like rast[is.na(other_rast)] <- NA worked with RasterLayers if they had resolutions that fit together even if they were different but doesn't work for terra SpatRaster unless the resolutions are the same

@see24 see24 closed this as completed in #19 Aug 23, 2022
@see24
Copy link
Member Author

see24 commented Jan 24, 2023

See this discussion from Alex about setting options if I come here looking for that https://for-cast.zulipchat.com/#narrow/stream/296360-r-help/topic/terra/near/322152043

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

Successfully merging a pull request may close this issue.

1 participant