Opened 19 months ago
Last modified 3 months ago
#5386 new defect
ST_MapAlgebra not respecting NULL nodatavalues
Reported by: | robe | Owned by: | robe |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 3.6.0 |
Component: | raster | Version: | 3.1.x |
Keywords: | Cc: |
Description
As someone noted on irc/matrix
If you have a NULL nodatavalue constraint on your raster table, and do something like
UPDATE yourtable SET rast = ST_MapAlgebra(rast,1, '32BF'::text, '[rast.val]*1'::text, NULL::float8);
You get a constraint vialoation
To test, I tested on demo.postgis.net in the nyc db, which has our development version of postgis running
CREATE TABLE test_robe AS SELECT * FROM o_2_nyc_dem; SELECT AddRasterConstraints('test_robe'::name, 'rast'::name); UPDATE test_robe SET rast = ST_MapAlgebra(rast,1, '16BUI'::text, '[rast.val]*1'::text, NULL::float8) WHERE rid = 1 ;
and received
ERROR: Failing row contains (1, 0100000100000000000000344000000000000034C09A999999FECA2B41333333..., nyc_dem.tif).new row for relation "test_robe" violates check constraint "enforce_nodata_values_rast"
The work around would be to set the bandnodata value as follows:
UPDATE test_robe SET rast = ST_SetBandNoDataValue(ST_MapAlgebra(rast,1, '16BUI'::text, '[rast.val]*1'::text, NULL::float8), NULL) WHERE rid = 1 ;
Change History (5)
comment:1 by , 19 months ago
comment:2 by , 19 months ago
I also tried the original signature:
st_mapalgebraexpr( rast raster, band integer, pixeltype text, expression text, nodataval double precision DEFAULT NULL::double precision)
and this also seems to ignore the input nodataval even calling by named args
SELECT ST_BandNoDataValue(st_mapalgebraexpr(rast => rast, band => 1, pixeltype => NULL, expression => '[rast.val]*1'::text, nodataval => 1)) FROM test_robe WHERE rid = 1 ;
comment:3 by , 19 months ago
Milestone: | PostGIS 3.0.9 → PostGIS 3.1.10 |
---|
comment:4 by , 13 months ago
Milestone: | PostGIS 3.1.10 → PostGIS 3.5.0 |
---|---|
Priority: | high → medium |
Version: | 3.3.x → 3.1.x |
comment:5 by , 3 months ago
Milestone: | PostGIS 3.5.0 → PostGIS 3.6.0 |
---|
Note:
See TracTickets
for help on using tickets.
Looking at this
What is returned is 0
but this also returns 0
I'm not sure if this is a bug, or just a documentation error. It might have become an issue when we merged all variants of ST_MapAlgebra under one umbrella.
https://postgis.net/docs/RT_ST_MapAlgebra_expr.html
Because the documentation speaks of using an expression to set no-data-value, and yet none of the signatures listed would allow that.