I have a public Google Drive folder containing dozens of raster files (.tif; folder here). I would like to download one file at the time and pass it through a function in r (then delete/replace the raster), without using oauth tokens (i.e. the tidyverse api packages).
The package "googledrive" seems to always ask for access to my Drive even though the folder is public. Is this correct? I am feeling hesitant handling oauth tokens and would prefer using a script that does not require it. Here is what I tried with the first file, but stopped there because tidyverse requested access:
library(googledrive)
temp <- tempfile(tmpdir = "C:/Temp", fileext = ".tif")
test <- drive_download(as_id("1StU410Ox_azZUmsFISElB8uXVsNx72mG"), path = temp, overwrite = TRUE)
I also tried the package curl:
library(curl)
id <- "1StU410Ox_azZUmsFISElB8uXVsNx72mG"
URL <- sprintf("https://drive.google.com/drive/folders/%s", id)
con <- curl(URL)
But don't know how to extract the raster from there.
Finally, I tried:
myUrl <- "https://drive.google.com/file/d/1StU410Ox_azZUmsFISElB8uXVsNx72mG/view?usp=sharing"
test <- raster(url(myUrl))
But got the following error message: Error in (function (classes, fdef, mtable): unable to find an inherited method for function ‘raster’ for signature ‘"url"’
Let me know if it is possible to read, in r, raster files saved in Google Drive, without tokens. Related to this question, is it possible to have a loop that goes from one file to the next in the Google Drive folder? Is there a way to extract the id of all the files in a Google Drive folder? I'm concerned about space if I download the whole folder.