Raster ST_Clip fails when a geometry either only touches or barely intersects.
I am trying to work on spatial statistics between a polygon and raster. My code works like 99.99+% of time but once in a while it fails because ST_Clip fails.
Below is an example case. As you see, when a polygon barely intersects with raster, I am getting "RASTER_clip: Could not get band from working raster". How do I work around it? In my application I have millions of polygons and raster table of hundreds of thousands of record. I use ST_Intersects(p.geom, r.rast) between table of polygons p and table of raster r, then ST_Clip(r.rast, p.geom).
psql:demo_clip_fail_barelyintersects.sql:16: 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