I have two rasters and I want to change all the values from "raster1" to 4, where they are larger than the values from "raster2" and to 0, where they are smaller.
So raster2 has only one value, which is 1.
raster1 has two values: 0,5 and 2
0,5 should change to 0 and 2 should change to 4
I tried with st_reclass and a case/when/else-argument, but then it changed ALL values to 0 or 4... Here's my code:
DROP TABLE IF EXISTS result_table; CREATE TABLE result_table AS SELECT p.id, case WHEN (pvc).value > (cvc).value THEN st_reclass(p.rast,1, '-999-999:4', '8BUI', NULL) ELSE st_reclass(p.rast,1, '-999-999:0', '8BUI', NULL) END AS rast FROM raster1 as p, raster2 as c, (select st_valuecount(dcp.rast) as pvc from raster1 as dcp) as pp, (Select st_valuecount(dcubc.rast) as cvc from raster2 as dcubc) as cc;
Ok, I could just reclass the values without looking up the other raster, but I want to do this multiple times with different rasters and values.