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

Loading terra resets terraOptions() #995

Closed
gpatoine opened this issue Jan 31, 2023 · 3 comments
Closed

Loading terra resets terraOptions() #995

gpatoine opened this issue Jan 31, 2023 · 3 comments

Comments

@gpatoine
Copy link

gpatoine commented Jan 31, 2023

I noticed an unexpected behavior, where loading terra resets terraOptions that had been set before. I do not know if this is on purpose, but it worked differently with raster. My use case was to set the options in the .Rprofile (based on the computer being used), which was quite convenient. I am not sure if this is a recent change.

> terra::terraOptions(tempdir = "H:/temp", memfrac = 0.4, memmax = 30)
> terra::terraOptions()
memfrac   : 0.4
tempdir   : H:/temp
datatype  : FLT4S
progress  : 3
todisk    : FALSE
verbose   : FALSE
tolerance : 0.1
memmin    : 1
memmax    : 30
> library(terra)
> terraOptions()
memfrac   : 0.6
tempdir   : C:/Users/username/AppData/Local/Temp/6/RtmpimL6I6
datatype  : FLT4S
progress  : 3
todisk    : FALSE
verbose   : FALSE
tolerance : 0.1
memmin    : 1 
@rhijmans
Copy link
Member

rhijmans commented Feb 1, 2023

When loading the package the options are not carried over from a previous session, and that would not be desirable.
But you are right that you could set your own defaults for "raster" by adding them to .Rprofile. I am not a big fan of that because it is just clearer to set things in a script, but I can understand that it can be convenient. The way that the options are handled by "terra" is a bit different, and I will add some code to support loading them from .Rprofile.

@rhijmans
Copy link
Member

rhijmans commented Feb 1, 2023

With commit 76bdb62 you can now set options in ".Rprofile.site" like this

options(terra_default=list(tempdir="d:/temp", memfrac=.4))

With these default options set, I get

library(terra)
#terra 1.7.6
terraOptions()
#datatype  : FLT4S
#memfrac   : 0.4
#tolerance : 0.1
#verbose   : FALSE
#verbose   : FALSE
#todisk    : FALSE
#tempdir   : d:/temp
#datatype  : FLT4S
#memmin    : 1
#progress  : 3

@rhijmans rhijmans closed this as completed Feb 1, 2023
@gpatoine
Copy link
Author

gpatoine commented Feb 1, 2023

Great, thank you for the quick response!
I ❤️ terra.

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

No branches or pull requests

2 participants