Closed Tartomas closed 4 years ago
There are couple of options:
res$encode = identity
in the raster_handler()
EncodeDecodeMiddleware
as described in #156Your example seems work fine:
library(RestRserve)
library(raster)
raster_handler = function(req, res) {
tmp <- tempdir()
r <- raster(system.file("external/test.grd", package="raster"))
# take a small part
r <- crop(r, extent(179880, 180800, 329880, 330840) )
tmp = tempfile(fileext = ".tif")
raster::writeRaster(r, filename=tmp, format="GTiff", overwrite=TRUE)
# form response
res$set_content_type("image/tiff")
# res$set_content_type("image/tiff")
res$set_body(c("tmpfile" = tmp))
res$encode = identity
}
app = Application$new()
app$add_get('/tiff', raster_handler)
back = BackendRserve$new()
back$start(app, 8080)
Another interesting question is how to serve cloud-optimized geotiff (COG) using range request... This is something we need to consider to implement.
Hi @dselivanov work perfect ! Just a question, do you know how can a reformat the filename? in order to get a human radeable as client_index_date.tif I just try it and it download a "tiff" image which response with the endpoint name. Thanks again
I'm not sure how to assign different name while serving file from disk.
Hello everyone, Thanks for your API system, work pretty well for my intentions. I'm just playing with Satellite information and I would like to create a endpoint to download a .tif file. It is a very common type of information in my field and I do not know how to implemented here as a serialized endpoint. I found that Plumber has a _*serializertiff(..., type = "image/tiff") function, that I think would work in a similar ways.
Please any would be great !