Skip to content
🌵SedonaDB (Rust) 0.3.0 is out now, featuring larger-than-memory spatial joins, and row-level CRS!

RS_AsPNG

Introduction: Returns a PNG byte array, that can be written to raster files as PNGs using the Sedona raster data source 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.

Note

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.

Note

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.

Format:

RS_AsPNG(raster: Raster)

RS_AsPNG(raster: Raster, maxWidth: Integer)

Return type: Binary

Since: v1.5.0

SQL Example

SELECT RS_AsPNG(raster) FROM Rasters

Output:

[-119, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73...]

SQL Example

SELECT RS_AsPNG(RS_Band(raster, Array(3, 1, 2)))

Output:

[-103, 78, 94, -26, 61, -16, -91, -103, -65, -116...]