[PostGIS] #6010: ST_SetBandNoDataValue can't handle infinite no data (was: ST_Polygon(rast) returns the box of the tile instead of multipolygons of only valued pixels.)

PostGIS trac at osgeo.org
Sun Nov 9 18:07:00 PST 2025


#6010: ST_SetBandNoDataValue can't handle infinite no data
-------------------------+-------------------------------------------------
  Reporter:              |      Owner:  robe
  GISuser5432            |
      Type:  defect      |     Status:  new
  Priority:  low         |  Milestone:  PostGIS 3.6.1
 Component:  raster      |    Version:  3.6.x
Resolution:              |   Keywords:  ST_Polygon (raster) ; Raster;
                         |  PostGIS_Raster;
-------------------------+-------------------------------------------------
Changes (by robe):

 * priority:  medium => low
 * summary:
     ST_Polygon(rast) returns the box of the tile instead of multipolygons
     of only valued pixels.
     => ST_SetBandNoDataValue can't handle infinite no data

Comment:

 I think the issue you have is not so much that ST_Polygon doesn't work but
 that your raster doesn't have the value you are trying to set.

 When I run:


 {{{
 SELECT (gv).val , ST_Area((gv).geom) AS nodata, ST_Area(rast::Geometry)
         FROM stpolygon_error, ST_DumpAsPolygons(rast) AS gv
 WHERE gv.val > 0;
 }}}

 I get one record and the val returns as infinity.


 {{{
    val    | nodata  | st_area
 ----------+---------+---------
  Infinity | 1836288 | 2022400
 (1 row)
 }}}


 I didn't think we allowed infinities in there but clearly I guess the
 value of your nodata is such a  large number that it's considered
 infinite.

 Sadly doing:


 {{{
 SELECT ST_Polygon(
 ST_SetBandNoDataValue(rast, 'Infinity')
 )
 FROM stpolygon_error;
 }}}


 Still does not output just the non-infinite part.

 But If I convert all your > 0 values to 100 and the others to -1. And mark
 100 as no-data, it returns what I'd expect (see attached image)


 {{{
 SELECT ST_Polygon(
 ST_Reclass(rast,1, 'Infinity:100,[-10000-0):1', '64BF', 100)
 )
 FROM stpolygon_error;
 }}}


 So I'm marking this as a low and changing the subject heading as the issue
 is not with ST_Polygon but that we can't handle all large numbers
 particularly with the ST_SetBandNoDataValue function


 [[Image(infinite_no_data.png)]]
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/6010#comment:1>
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