I have a set of raster geotif files in a bucket in google cloud storage that I would like to read and use in a web platform (like shiny).
To connect and download the data I am using googleCloudStorageR library and to display the raster I am using raster library.
Below is an example of the code to download a tif and then read it with raster library as any regular tif file which works fine.
library(googleCloudStorageR)
library(raster)
...authenthication and set bucket of interest (data omitted)...
#Download to a tif file and plot
download <- gcs_get_object(objects$name[[post]], bucket=bucket, saveToDisk = filegeo1.tif, overwrite = TRUE)
r1<-raster(filegeo1.tif)
plot(r1)
However, what I want is to able to read into memory the data and plot without saving into a tif file locally.
#Download to raw in memory
raw_raster <- gcs_get_object(objects$name[[post]], bucket=bucket, saveToDisk = NULL)
str(raw_raster)
raw_raster
saveRDS(raw_raster, file = "raw_raster_from_googlecloudstorage.Rds")
The result of the above commands can be seen like: Screenshot of console result
I saved the file as Rds so anyone can have a use it for testing purposes in this open link to download file in mega storage. If I could transform from this raw data to geotif it would be great and would solve my situation.
I have read other question reported about reading geotiff data straight from web URL but is not the same since I don't have an url for each file. So what advice can you provide? I appreciate the help. Thank you,