#5410 closed defect (fixed)

ST_Value throws an error "ERROR: rt_band_get_nodata: Band has no NODATA value" if bilinear is chosen as a sampling option

Reported by: robe Owned by: robe
Priority: medium Milestone: PostGIS 3.2.6
Component: raster Version: 3.2.x
Keywords: Cc:

Description

This was noted in IRC by JohnSmit99

Below from IRC notes

this works: ```select ST_Value(rast, ST_SetSRID(ST_MakePoint(20,20), 4326)) as val from mytable WHERE ST_Intersects(rast, ST_SetSRID(ST_MakePoint(20, 20), 4326)) AND timestamp = '2016-01-10 12:00:00';```
12:22PM
this does NOT work: ```select ST_Value(rast, 1, ST_SetSRID(ST_MakePoint(20,20), 4326), true, 'bilinear') as val from mytable WHERE ST_Intersects(rast, ST_SetSRID(ST_MakePoint(20, 20), 4326)) AND timestamp = '2016-01-10 12:00:00';
12:22PM
ERROR:  rt_band_get_nodata: Band has no NODATA value```
12:23PM
the band indeed has no NODATA value, but I don't see how this should make the command fail
12:23PM
POSTGIS="3.3.2 0" [EXTENSION] PGSQL="150" GEOS="3.11.1-CAPI-1.17.1" PROJ="9.1.0" GDAL="GDAL 3.5.3, released 2022/10/21" LIBXML="2.10.4" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER

The issue I think is https://git.osgeo.org/gitea/postgis/postgis/src/branch/master/raster/rt_core/rt_band.c#L1297 #in the rt_band_get_pixel_bilinear function

The rt_band_get_nodata exits the whole process. I think band->hasnodata has to be checked first before calling rt_band_get_nodata or alternatively change rt_band_get_nodata to use

rtwarn instead of rterror when erroring out.

Changing rt_band_get_nodata makes more sense to me, but not sure the ramifications of that as this function is used all over the place.

Change History (5)

comment:1 by strk, 17 months ago

It's safer not to change the existing function but rather do the pre-check

comment:2 by Regina Obe <lr@…>, 17 months ago

Resolution: fixed
Status: newclosed

In 84e7fd2/git:

ST_Value bilinear

  • Don't throw an error if nodatavalue, instead use 0
  • Add tests for bilinear

Closes #5410 for PostGIS 3.4.0dev

comment:3 by robe, 17 months ago

Resolution: fixed
Status: closedreopened

Oops didn't mean to close until I backported to 3.3 and 3.2

comment:4 by Regina Obe <lr@…>, 17 months ago

In fbbf5fd/git:

ST_Value bilinear

  • Don't throw an error if nodatavalue, instead use 0
  • Add tests for bilinear

References #5410 for PostGIS 3.3.4

comment:5 by Regina Obe <lr@…>, 17 months ago

Resolution: fixed
Status: reopenedclosed

In b8bdce6/git:

ST_Value bilinear

  • Don't throw an error if nodatavalue, instead use 0
  • Add tests for bilinear

Closes #5410 for PostGIS 3.2.6

Note: See TracTickets for help on using tickets.