[postgis-tickets] [PostGIS] #3457: When a geometry is smaller than a raster but their extents are the same, one of the overloads of ST_Clip doesn't give expected output
PostGIS
trac at osgeo.org
Tue Oct 23 05:29:11 PDT 2018
#3457: When a geometry is smaller than a raster but their extents are the same,
one of the overloads of ST_Clip doesn't give expected output
-----------------------+---------------------------
Reporter: GMudambi | Owner: Bborie Park
Type: defect | Status: new
Priority: critical | Milestone: PostGIS 2.4.6
Component: raster | Version: 2.1.x
Resolution: | Keywords:
-----------------------+---------------------------
Comment (by saibot):
Dear Jiří, users and developers,
the st_clip function works incorrectly. I strongly recommend the following
correction to all users. I hope that the bug will be fixed soon.
{{{
CREATE OR REPLACE FUNCTION public.st_clip(
rast RASTER, nband INTEGER [], geom GEOMETRY,
nodataval DOUBLE PRECISION [] DEFAULT NULL :: DOUBLE PRECISION [],
crop BOOLEAN DEFAULT TRUE)
RETURNS RASTER AS
$BODY$
BEGIN
-- wrong version
-- short-cut if geometry's extent fully contains raster's extent
-- IF (nodataval IS NULL OR array_length(nodataval, 1) < 1) AND geom ~
ST_Envelope(rast)
-- corrected version (bug-fix)
-- no more short-cut!!! if geometry's extent fully contains raster's
extent
IF (nodataval IS NULL OR array_length(nodataval, 1) < 1) AND
st_contains(geom, ST_Envelope(rast))
THEN RETURN rast;
END IF;
RETURN PUBLIC._ST_Clip($1, $2, $3, $4, $5);
END;
$BODY$
LANGUAGE plpgsql
IMMUTABLE
COST 100;
}}}
Thank you for all your work and best regards,
Sai-bot
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/3457#comment:8>
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