2

I have a raster column with "NoData" value of 3.40282346638529e+038 in PostGIS. I want to change the NoData value to 100. I used the following code:

SELECT ST_Reclass(ukc,1,'3.40282346638529e+038:100', '32BF', 3.40282346638529e+038) rast
INTO for_delete1
FROM raster_table

but it changed all pixel values to 3.40282346638529e+038 and it changed non of the NoData pixels!! then, I used the same query and just changed '3.40282346638529e+038:100' to '100:3.40282346638529e+038'. This one also made some strange changes but the NoData value is still the same.

How can I change the NoData value for a raster column in PostGIS?

1 Answer 1

2

I found the solution. In fact the third input of ST_Reclass() should be two sets of range not single values. So I changed it to:

SELECT ST_Reclass(ukc,1,'3.40282346638529e+037-3.50282346638529e+038:100, -20-20:-20-20', '32BF') rast
INTO for_delete1
FROM raster_table

This Code finds the values between 3.40282346638529e+037 and 3.50282346638529e+038 and then change them to 100. In addition, it map the values between -20 to 20 to the same range because the pixel values are between -20 and 20. Thus, the pixel values are not changed and the NoData value is changed to 100.

At the end, the NoData value should be defined for the column by:

UPDATE for_delete1
SET rast = ST_SetBandNoDataValue(rast, 1, 100::double precision);

This way, PostGIS knows that 100 will be considered as the new NoData value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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