Skip to main content
Returns a PNG byte array, that can be written to raster files as PNGs using the Sedona raster writer. This function can only accept pixel data type of unsigned integer. PNG can accept 1 or 3 bands of data from the raster, refer to RS_Band for more details.
Raster having UNSIGNED_8BITS pixel data type will have range of 0 - 255, whereas rasters having UNSIGNED_16BITS pixel data type will have range of 0 - 65535. If provided pixel value is greater than either 255 for UNSIGNED_8BITS or 65535 for UNSIGNED_16BITS, then the extra bit will be truncated.
Raster that have float or double values will result in an empty byte array. PNG only accepts Integer values, if you want to write your raster to an image file, please refer to RS_AsGeoTiff.

Signatures

RS_AsPNG(raster: Raster)
RS_AsPNG(raster: Raster, maxWidth: Integer)

Parameters

raster
Raster
required
The input raster.
maxWidth
Integer
The maximum width of the output PNG.

Return type

The raster as a PNG byte array.

Examples

SELECT RS_AsPNG(raster) FROM Rasters
[-119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73...]

With band reordering

SELECT RS_AsPNG(RS_Band(raster, Array(3, 1, 2)))
[-103, 78, 94, -26, 61, -16, -91, -103, -65, -116...]