Opened 9 months ago

Last modified 4 months ago

#3725 new defect

[raster] ST_Clip with multiple band raster throws exception when geometry only touches

Reported by: yosukesabai Owned by: dustymugs
Priority: medium Milestone: PostGIS 2.5.0
Component: raster Version: 2.3.x
Keywords: Cc:

Description

I realized that ST_Clip(raster, geometry) gives following error message under particular condition:

ERROR: RASTER_clip: Could not get band from working raster CONTEXT: PL/pgSQL function st_clip(raster,integer[],geometry,double precision[],boolean) line 8 at RETURN

This happens, I think, when (1) raster has multi-band and (2) raster and geometry (polygon) touches with no shared interior. Below is example sql command for demo.

My version

version()
PostgreSQL 9.6.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.9.1, 64-bit

postgis_full_version()
POSTGIS="2.3.1 r15264" GEOS="3.6.0-CAPI-1.10.0 r0" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.1 .2, released 2016/10/24" LIBXML="2.9.4" LIBJSON="0.12.1" RASTER

-- This fails
SELECT ST_Summary(
        ST_Clip(
                ST_AddBand(
                        ST_MakeEmptyRaster(16, 16, 0, 0, 1, 1, 0, 0),
                        ARRAY[
                        ROW(1, '8BUI'::text, 0, 255),
                        ROW(2, '8BUI'::text, 0, 255),
                        ROW(3, '8BUI'::text, 0, 255)
                        ]::addbandarg[]
                ),
                ST_GeomFromText('POLYGON((16 0, 16 1, 17 1, 17 0, 16 0))')
        )
);

Change History (2)

comment:1 Changed 6 months ago by robe

Component: postgisraster
Milestone: PostGIS 2.3.3PostGIS 2.4.0
Owner: changed from pramsey to dustymugs

As noted in #3730, changed the error to a NOTICE.

I'm pushing this one to PostGIS 2.4, because I think we might be able to do better than that by perhaps adding an extra arg to ST_Clip if a touched pixel should be returned. I recall we had discussions about it before.

comment:2 Changed 4 months ago by dbaston

Milestone: PostGIS 2.4.0PostGIS 2.5.0
Note: See TracTickets for help on using tickets.