[postgis-devel] [PostGIS] #1792: [raster] ST_Intersection returns false positives

PostGIS trac at osgeo.org
Thu Apr 26 12:16:46 PDT 2012

#1792: [raster] ST_Intersection returns false positives
 Reporter:  febus982  |       Owner:  pramsey      
     Type:  defect    |      Status:  new          
 Priority:  high      |   Milestone:  PostGIS 2.0.1
Component:  postgis   |     Version:  2.0.x        
 Keywords:            |  
 Software and DB Structure:
 PostgreSQL 9.1.3
 GEOS 3.3.2
 GDAL 1.9.0

 Table 1 (vector):
 Single column (geom) - About 100.000 points geometries exported with GRASS
 6.4.2 (v.out.ogr command).

 Table 2 (raster):
 Column 1 (rast): raster column
 Column 2 (filename): filename

 Raster is geotiff file imported with:
 /usr/lib/postgresql/9.1/bin/raster2pgsql -s 4326 -a -Y -F -t 20x20

 View 1:
  SELECT v.geom, r.filename, st_value(r.rast, v.geom) AS value
    FROM vector v, raster r
   WHERE r.filename = 'file.tif'::text AND st_intersects(r.rast, 1,

 I got multiple points in this view values (some are null values)
 They are all aligned on same X and/or same Y.

 If i materialize this view in a table using:
 CREATE TABLE table AS SELECT...... (same command)
 I got a bunch of notices in console:
 st_intersects NOTICE: Attempting to get pixel value with out of range
 raster coordinates:

 View 2:
  SELECT v.geom, r.filename, st_value(r.rast, v.geom) AS value
    FROM geoserver_layers.z1 v, raster.raster r
   WHERE r.filename = '2012042611_me.tif'::text AND st_intersects(r.rast,
 1, v.geom) AND st_value(r.rast, v.geom) IS NOT NULL;

 I Tried filtering out NULL values by adding "st_value(r.rast, v.geom) IS
 NOT NULL" but I got some points missing instead of multiple points;

 This happens in all forms of ST_Intersects
 st_intersects(v.geom, r.rast, 1)
 st_intersects(r.rast, 1, v.geom)

 I Tried also changing tile size in raster2pgsql

Ticket URL: <http://trac.osgeo.org/postgis/ticket/1792>
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-devel mailing list