Internal function to create JPEG images from a multiband raster file. This function is used by s2_thumbnails, and it will be exported when it would be more generalised.

stack2rgb(in_rast, out_file = NULL, bands = 1:3, minval = 0,
  maxval = 10000, format = "JPEG", compress = "90", tmpdir = NA)

Arguments

in_rast

Path of the input multiband raster.

out_file

(optional) Path of the output RGB JPEG image; if NULL (default), a RasterBrick will be returned.

bands

(optional) 3-length integer argument, with the position of the three bands to be used respectively for red, green and blue.

minval

(optional) the value corresponding to black (default: 0). Also a 3-length vector is accepted (min values for red, green and blue respectively).

maxval

(optional) the value corresponding to white (default: 10000). Also a 3-length vector is accepted (max values for red, green and blue respectively).

format

(optional) Format of the output file (in a format recognised by GDAL). Default is JPEG.

compress

(optional) In the case a GTiff format is present, the compression indicated with this parameter is used. In the case a JPEG format is present, the compression indicates the quality (integer, 0-100). In the case a GTiff format is presentand an integer 0-100 number is provided, this is interpreted as the quality level of a JPEG compression.

tmpdir

(optional) Path where intermediate files will be created. Default is a temporary directory.

Value

The path of the output image; alternatively, the output image as RasterBrick (if out_rast = NULL).

Note

License: GPL 3.0