0

Link to question/answer similar to what I am trying to do

I am trying to run ST_RECLASS on a raster to retain certain pixel values while setting others to NoData(0). I have a function that creates a lookup table and then I embed the lookup table within the UPDATE query using ST_RECLASS to try to reassign the output pixel valuese.

The raster, before relcass attempt, has these values: (BEC_ZONE_CLIP_RASTER_RASTER)

Raster Values

My lookup table contains the following values: (ZZ_TMP_LOOKUP)

enter image description here

When I execute the following line of code:

UPDATE BEC_ZONE_CLIP_RASTER_RASTER SET rast = ST_Reclass(rast, ROW(1, (SELECT string_agg(concat('[', val, ']:', out_val), ',')  FROM zz_tmp_lookup), '4BUI', 0)::reclassarg);

I end up with the pixels that represent 17 and 21 values reclassed, but they are set to value 15. Can somebody help me to understand why this is happening?

enter image description here

1

So, I was stuck in a big rut here and clearly could not see the obvious. I had '4BUI' as the output Pixel Type. That type can only handle 16 values, which, when you include NoData 0 leaves 15 as the max value available. Changed to '32BUI' and all is well

UPDATE BEC_ZONE_CLIP_RASTER_RASTER SET rast = ST_Reclass(rast, ROW(1, (SELECT string_agg(concat('[', val,'-', val, ']:', out_val::INTEGER), ',')  FROM (SELECT VAL, OUT_VAL from zz_tmp_lookup where out_val <> 0 order by val asc) foo), '32BUI', 0)::reclassarg);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.