ropensci / osmextract

Download and import OpenStreetMap data from Geofabrik and other providers
https://docs.ropensci.org/osmextract
GNU General Public License v3.0
170 stars 12 forks source link

[FEATURE] Replace tempdir() with R_user_dir() #302

Open agila5 opened 2 weeks ago

agila5 commented 2 weeks ago

The R 4.0.0 NEWS file says:

New function R_user_dir() in package tools suggests paths appropriate for storing R-related user-specific data, configuration and cache files.

For example, I currently see:

`tools::R_user_dir("osmextract", "data")`
#> [1] "C:\\Users\\user\\AppData\\Roaming/R/data/R/osmextract"

I think that the ideas behind this function are somewhat related to the approach we currently use to detect where osmextract functions will save .osm and .gpkg files, i.e.

https://github.com/ropensci/osmextract/blob/0eeacf8c725d66a93fec6e8ef9112178e6071db2/R/utils.R#L72-L78

Currently, we set the download directory as tempdir() whenever the OSMEXT_DOWNLOAD_DIRECTORY envvar is not set.

Does it make sense switching to tools::R_user_dir("osmextract", "data")?

Robinlovelace commented 2 weeks ago

Cool! Yes could make sense to use that if there is now env var.