Dear community,
I have a plumber endpoint that accept a tiff file.
The plumber api should firt create the raster file and apply a simple operations.
after the operation, the raster must be convert to "raw" vector and pass this to the plumber::as_attachment()
function.
I will attach the code that i have developed in order to do so, but i have a problem to convert the modified raster to "raw" vector.
#* @tag RasterOperation
#* @param raster:binary
#* @post /RasterOperation
#* @serializer octet
function(raster){
fn <- names(raster)
print(fn)
content <- raster[[1]]
print(content)
writeBin(content, con = "raster.tif")
raster_file <- raster::raster("raster.tif")
raster_file<-raster_file*77.447-9.0073
unlink("raster.tif", force = T)
writeBin(raster_file, con = "raster.tif")
bin_raster<-readBin("raster.tif", what = "raw", n=length(content))
plumber::as_attachment(bin_raster, fn)
}
Thanks to any support