[postgis-tickets] [PostGIS] #5386: ST_MapAlgebra not respecting NULL nodatavalues

PostGIS trac at osgeo.org
Fri May 19 04:14:49 PDT 2023


#5386: ST_MapAlgebra not respecting NULL nodatavalues
--------------------+---------------------------
 Reporter:  robe    |      Owner:  robe
     Type:  defect  |     Status:  new
 Priority:  high    |  Milestone:  PostGIS 3.0.9
Component:  raster  |    Version:  3.3.x
 Keywords:          |
--------------------+---------------------------
 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 ;
 }}}
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5386>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list