Opened 4 years ago

Closed 4 years ago

#2260 closed enhancement (fixed)

rasql - error in encode with colorPalette by PNG format

Reported by: Bang Pham Huu Owned by: apercov
Priority: major Milestone: 10.0
Component: rasql Version: 9.8
Keywords: Cc: Dimitar Misev, Vlad Merticariu
Complexity: Medium

Description

The real use case is when one tries to colorize e.g: UInt16 satellite image with 256 values from colorPalette option, it returns not user-friendly error. In this case, one needs to cast the MDD to char.

For example the testing query below with test_mr collection:

rasql -q 'SELECT ENCODE( (ushort) ( Scale( ( ( c0[0:0, 0:0] ) ), [0:255, 0:255] ) ) , "png", "{ \"colorPalette\" : { \"colorTable\" : [ [ 255, 242, 1, 255 ], [ 255, 241, 1, 255 ], [ 255, 240, 1, 255 ], [ 255, 238, 1, 255 ], [ 255, 237, 1, 255 ], [ 255, 236, 1, 255 ], [ 255, 235, 1, 255 ], [ 255, 234, 1, 255 ], [ 255, 233, 1, 255 ], [ 255, 231, 1, 255 ], [ 255, 230, 1, 255 ], [ 255, 229, 1, 255 ], [ 255, 228, 1, 255 ], [ 255, 227, 1, 255 ], [ 255, 226, 1, 255 ], [ 255, 224, 1, 255 ], [ 255, 223, 1, 255 ], [ 255, 222, 1, 255 ], [ 255, 221, 1, 255 ], [ 255, 220, 1, 255 ], [ 255, 219, 1, 255 ], [ 255, 217, 1, 255 ], [ 255, 216, 1, 255 ], [ 255, 215, 1, 255 ], [ 255, 214, 1, 255 ], [ 255, 213, 1, 255 ], [ 255, 212, 0, 255 ], [ 255, 210, 0, 255 ], [ 255, 209, 0, 255 ], [ 255, 208, 0, 255 ], [ 255, 207, 0, 255 ], [ 255, 206, 0, 255 ], [ 255, 205, 0, 255 ], [ 255, 203, 0, 255 ], [ 255, 202, 0, 255 ], [ 255, 201, 0, 255 ], [ 255, 200, 0, 255 ], [ 255, 199, 0, 255 ], [ 255, 197, 0, 255 ], [ 255, 196, 0, 255 ], [ 255, 195, 0, 255 ], [ 255, 194, 0, 255 ], [ 255, 193, 0, 255 ], [ 255, 192, 0, 255 ], [ 255, 190, 0, 255 ], [ 255, 189, 0, 255 ], [ 255, 188, 0, 255 ], [ 255, 187, 0, 255 ], [ 255, 186, 0, 255 ], [ 255, 185, 0, 255 ], [ 255, 183, 0, 255 ], [ 255, 182, 0, 255 ], [ 255, 181, 0, 255 ], [ 255, 180, 0, 255 ], [ 255, 179, 0, 255 ], [ 255, 177, 0, 255 ], [ 255, 176, 0, 255 ], [ 255, 175, 0, 255 ], [ 255, 174, 0, 255 ], [ 255, 173, 0, 255 ], [ 255, 172, 0, 255 ], [ 255, 170, 0, 255 ], [ 255, 169, 0, 255 ], [ 255, 168, 0, 255 ], [ 255, 167, 0, 255 ], [ 255, 166, 0, 255 ], [ 255, 164, 0, 255 ], [ 255, 163, 0, 255 ], [ 255, 162, 0, 255 ], [ 255, 161, 0, 255 ], [ 255, 160, 0, 255 ], [ 255, 159, 0, 255 ], [ 255, 157, 0, 255 ], [ 255, 156, 0, 255 ], [ 255, 155, 0, 255 ], [ 255, 154, 0, 255 ], [ 255, 153, 0, 255 ], [ 254, 151, 0, 255 ], [ 254, 150, 0, 255 ], [ 254, 149, 0, 255 ], [ 254, 148, 0, 255 ], [ 254, 147, 0, 255 ], [ 254, 146, 0, 255 ], [ 254, 144, 0, 255 ], [ 254, 143, 0, 255 ], [ 254, 142, 0, 255 ], [ 254, 141, 0, 255 ], [ 254, 140, 0, 255 ], [ 254, 138, 0, 255 ], [ 254, 137, 0, 255 ], [ 254, 136, 0, 255 ], [ 254, 135, 0, 255 ], [ 254, 134, 0, 255 ], [ 254, 133, 0, 255 ], [ 254, 131, 0, 255 ], [ 254, 130, 0, 255 ], [ 254, 129, 0, 255 ], [ 254, 128, 0, 255 ], [ 254, 127, 0, 255 ], [ 254, 125, 0, 255 ], [ 254, 124, 0, 255 ], [ 254, 123, 0, 255 ], [ 254, 122, 0, 255 ], [ 254, 121, 0, 255 ], [ 254, 120, 0, 255 ], [ 254, 118, 0, 255 ], [ 254, 117, 0, 255 ], [ 254, 116, 0, 255 ], [ 254, 115, 0, 255 ], [ 254, 114, 0, 255 ], [ 254, 113, 0, 255 ], [ 254, 111, 0, 255 ], [ 254, 110, 0, 255 ], [ 254, 109, 0, 255 ], [ 254, 108, 0, 255 ], [ 254, 107, 0, 255 ], [ 254, 105, 0, 255 ], [ 254, 104, 0, 255 ], [ 254, 103, 0, 255 ], [ 254, 102, 0, 255 ], [ 254, 101, 0, 255 ], [ 254, 100, 0, 255 ], [ 254, 98, 0, 255 ], [ 254, 97, 0, 255 ], [ 254, 96, 0, 255 ], [ 254, 95, 0, 255 ], [ 254, 94, 0, 255 ], [ 254, 93, 0, 255 ], [ 254, 91, 0, 255 ], [ 253, 90, 0, 255 ], [ 253, 89, 0, 255 ], [ 253, 88, 0, 255 ], [ 253, 87, 0, 255 ], [ 253, 86, 0, 255 ], [ 253, 84, 0, 255 ], [ 253, 83, 0, 255 ], [ 253, 82, 0, 255 ], [ 253, 81, 0, 255 ], [ 253, 80, 0, 255 ], [ 253, 79, 0, 255 ], [ 253, 77, 0, 255 ], [ 253, 76, 0, 255 ], [ 253, 75, 0, 255 ], [ 253, 74, 0, 255 ], [ 253, 73, 0, 255 ], [ 253, 72, 0, 255 ], [ 253, 70, 0, 255 ], [ 253, 69, 0, 255 ], [ 253, 68, 0, 255 ], [ 253, 67, 0, 255 ], [ 253, 66, 0, 255 ], [ 253, 65, 0, 255 ], [ 253, 63, 0, 255 ], [ 253, 62, 0, 255 ], [ 253, 61, 0, 255 ], [ 128, 177, 7, 255 ], [ 126, 176, 7, 255 ], [ 125, 175, 7, 255 ], [ 123, 175, 7, 255 ], [ 121, 174, 7, 255 ], [ 119, 173, 6, 255 ], [ 118, 172, 6, 255 ], [ 116, 172, 6, 255 ], [ 114, 171, 6, 255 ], [ 113, 170, 6, 255 ], [ 111, 169, 6, 255 ], [ 109, 169, 6, 255 ], [ 108, 168, 6, 255 ], [ 106, 167, 6, 255 ], [ 104, 166, 6, 255 ], [ 103, 165, 6, 255 ], [ 101, 165, 5, 255 ], [ 100, 164, 5, 255 ], [ 98, 163, 5, 255 ], [ 96, 162, 5, 255 ], [ 95, 162, 5, 255 ], [ 93, 161, 5, 255 ], [ 92, 160, 5, 255 ], [ 90, 159, 5, 255 ], [ 89, 158, 5, 255 ], [ 87, 158, 5, 255 ], [ 86, 157, 5, 255 ], [ 84, 156, 4, 255 ], [ 83, 155, 4, 255 ], [ 81, 155, 4, 255 ], [ 80, 154, 4, 255 ], [ 78, 153, 4, 255 ], [ 77, 152, 4, 255 ], [ 75, 151, 4, 255 ], [ 74, 151, 4, 255 ], [ 73, 150, 4, 255 ], [ 71, 149, 4, 255 ], [ 70, 148, 4, 255 ], [ 68, 147, 4, 255 ], [ 67, 147, 3, 255 ], [ 66, 146, 3, 255 ], [ 64, 145, 3, 255 ], [ 63, 144, 3, 255 ], [ 62, 143, 3, 255 ], [ 60, 143, 3, 255 ], [ 59, 142, 3, 255 ], [ 58, 141, 3, 255 ], [ 56, 140, 3, 255 ], [ 55, 140, 3, 255 ], [ 54, 139, 3, 255 ], [ 52, 138, 3, 255 ], [ 51, 137, 3, 255 ], [ 50, 136, 3, 255 ], [ 49, 136, 2, 255 ], [ 47, 135, 2, 255 ], [ 46, 134, 2, 255 ], [ 45, 133, 2, 255 ], [ 44, 132, 2, 255 ], [ 43, 132, 2, 255 ], [ 41, 131, 2, 255 ], [ 40, 130, 2, 255 ], [ 39, 129, 2, 255 ], [ 38, 128, 2, 255 ], [ 37, 127, 2, 255 ], [ 36, 127, 2, 255 ], [ 35, 126, 2, 255 ], [ 33, 125, 2, 255 ], [ 32, 124, 2, 255 ], [ 31, 123, 1, 255 ], [ 30, 123, 1, 255 ], [ 29, 122, 1, 255 ], [ 28, 121, 1, 255 ], [ 27, 120, 1, 255 ], [ 26, 119, 1, 255 ], [ 25, 119, 1, 255 ], [ 24, 118, 1, 255 ], [ 23, 117, 1, 255 ], [ 22, 116, 1, 255 ], [ 21, 115, 1, 255 ], [ 20, 114, 1, 255 ], [ 19, 114, 1, 255 ], [ 18, 113, 1, 255 ], [ 17, 112, 1, 255 ], [ 16, 111, 1, 255 ], [ 15, 110, 1, 255 ], [ 14, 110, 1, 255 ], [ 14, 109, 1, 255 ], [ 13, 108, 0, 255 ], [ 12, 107, 0, 255 ], [ 11, 106, 0, 255 ], [ 10, 105, 0, 255 ], [ 9, 105, 0, 255 ], [ 8, 104, 0, 255 ], [ 8, 103, 0, 255 ], [ 7, 102, 0, 255 ], [ 6, 101, 0, 255 ], [ 5, 100, 0, 255 ], [ 4, 100, 0, 255 ], [ 4, 99, 0, 255 ], [ 3, 98, 0, 255 ], [ 255, 255, 255, 255 ] ] }, \"nodata\" : [ 0.0 ] }") 

FROM test_mr AS c0'

with error

conversion/gdal.cc:189: Failed encoding to format 'png': libpng: Invalid IHDR data
rasdaman error 381: Execution error 381 in line 1, column 8, near token ENCODE: Error in convertor of the selected data exchange format.

Change History (4)

comment:1 by Dimitar Misev, 4 years ago

@apercov you'll need to add a check in gdal.cc convertTo:

if the encode options has a color palette table specified and the data is not base type char

  • log a warning "MDD has a non-char cell type, cannot apply color palette table."
  • skip setting the color palette table

comment:2 by Dimitar Misev, 4 years ago

Actually better just throw an exception, a warning will be confusing.

comment:3 by apercov, 4 years ago

Status: assignedaccepted

comment:4 by apercov, 4 years ago

Resolution: fixed
Status: acceptedclosed
Note: See TracTickets for help on using tickets.