Note can use scale=0,1
to convert literally any raster to image this way too.
a raster source for GDAL
target crs (optional)
target extent (optional, xmin,xmax,ymin,ymax)
target dimension (optional, ncol,nrow - one value can be 0)
target resolution (optional, resx, resy)
which bands to read (we could read just the second green band, for example)
optional resampling algo (near is default, use bilinear or cubic or see GDAL doc)
keep quiet
options for the gdalwarp binary (can use c("-tr", xres, yres) in place of target_res for example)
list in ximage() gdal_raster_ format as per vapour package
dsn <- "vrt:///vsicurl/http://s3.amazonaws.com/com.modestmaps.bluemarble/0-r0-c0.jpg"
dsn <- paste0(dsn, "?a_ullr=-20037508,20037508,20037508,-20037508&a_srs=EPSG:900913")
gdal_raster_nara(dsn, target_dim = c(36, 36))
#> gdalinfo - unable to open 'vrt:///vsicurl/http://s3.amazonaws.com/com.modestmaps.bluemarble/0-r0-c0.jpg?a_ullr=-20037508,20037508,20037508,-20037508&a_srs=EPSG:900913'.
#> Error in vapour_raster_info(dsn[1]): GDAL was unable to open ^^
#png <- system.file("img", "Rlogo.png", package="png")
## for dumb imagery we need to specify NO_GEOTRANSFORM or set the native affine transform
#gdal_raster_nara(sprintf("vrt://%s?a_gt =0,1,0,76,0,-1", png)) #, options = c("-to", "SRC_METHOD=NO_GEOTRANSFORM"))