Reading rasters from URLs (Without temp files)

Hi there,

I have an API I've developed that generates a .tiff file and returns it. When calling it in programs such as Postman or via a web browser I get a file returned.

I'm trying to load the image into a raster type in R but cannot figure out how to do this. I've tried using httr and the GET() function but the image is just returned as a raw vector and I cannot turn this into a raster.

Is there a way to do this without having to actually download the file temporarily and then make a raster object from that?

I'd rather not have to clean up temporary files constantly.

Many thanks,


I don't think so, you can certainly read NetCDF from URLs with ncdf4 or RNetCDF and in some cases with rgdal/raster, but I don't think GeoTIFF can work that way.

(In some contexts I use Sys.setenv(GDAL_SKIP="DODS") to avoid driver conflation).

There's ongoing work on "Cloud Optimized GeoTIFF" that might be worth exploring, but I'm not across it.

Thanks for the reply @mdsumner, in the end I just used a temporary file and would override that if a new image needed to be downloaded. Didn't seem to be any other 'good' way to go about it.