[PostGIS] #6010: ST_Polygon(rast) returns the box of the tile instead of multipolygons of only valued pixels.

PostGIS trac at osgeo.org
Tue Oct 28 14:29:27 PDT 2025


#6010: ST_Polygon(rast) returns the box of the tile instead of multipolygons of
only valued pixels.
-------------------------------------------------+-------------------------
 Reporter:  GISuser5432                          |      Owner:  robe
     Type:  defect                               |     Status:  new
 Priority:  medium                               |  Milestone:  PostGIS
                                                 |  3.6.1
Component:  raster                               |    Version:  3.6.x
 Keywords:  ST_Polygon (raster) ; Raster;        |
  PostGIS_Raster;                                |
-------------------------------------------------+-------------------------
 I have tested PostGIS 3.5.2 and 3.6 and in both of them ST_Polygon(rast)
 returns the box of the tile (something like ST_Envelope).

 It is supposed to ignore NoData pixels but they are well included in the
 resulting rectangular polygon!

 If we use this query and open the result in QGIS we will see the tile
 extent (NoData pixels exist in this box!):

 This is the simple query:

 {{{#!div style="font-size: 80%"
 Code highlighting:
   {{{#!sql
 SELECT ST_Polygon(
 ST_SetBandNoDataValue(rast, 1.7976931348623157e+308)
 )
 FROM stpolygon_error
   }}}
 }}}

 I added explicit NoData value declaration to make sure that the error is
 not because of this.

 I used a docker image of postgis with these details:


 {{{

 POSTGIS="3.6.0 4c1967d" [EXTENSION] PGSQL="180" GEOS="3.13.1-CAPI-1.19.2"
 PROJ="9.6.0 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org
 USER_WRITABLE_DIRECTORY=/var/lib/postgresql/.local/share/proj
 DATABASE_PATH=/usr/share/proj/proj.db" (compiled against PROJ 9.6.0)
 GDAL="GDAL 3.10.3, released 2025/04/01" LIBXML="2.9.14" LIBJSON="0.18"
 LIBPROTOBUF="1.5.1" WAGYU="0.5.0 (Internal)" RASTER

 }}}

 The red polygon is the result of ST_Polygon(rast) and 70% of the image at
 right side is filled with NoData values.

 [[Image(polygonError.JPG)]]


 A Table called stpolygon_error with a single row of raster is dumped and
 attached for test.
-- 
Ticket URL: <https://trac.osgeo.org/postgis/ticket/6010>
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