Opened 8 years ago

Closed 7 years ago

#3730 closed defect (fixed)

[raster] ST_Clip fails when polygon barely intersects with raster

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

Description

It would be better if this returns one pixel, or nothing at all. Currently it throws ERROR and I found hard to handle the error in PG/SQL.

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[]
    )
    -- this works
    --, ST_GeomFromText('POLYGON((15.999999 15.999999, 15.999999 17, 17 17, 17 15.999999, 15.999999 15.999999))')
    -- this fails
    , ST_GeomFromText('POLYGON((15.9999999 15.9999999, 15.9999999 17, 17 17, 17 15.9999999, 15.9999999 15.9999999))')
  )
);

Change History (5)

comment:1 by robe, 8 years ago

Component: postgisraster
Owner: changed from pramsey to Bborie Park

comment:2 by robe, 7 years ago

Owner: changed from Bborie Park to robe

comment:3 by robe, 7 years ago

In 15456:

Change ST_Clip from Error to Notice when ST_Clip can compute no band
References #3730 for PostGIS 2.4

comment:4 by robe, 7 years ago

I changed this from Erroring to just providing a NOTICE and returning NULL as it was before.

I notice that when the geometry doesn't intersect the raster, it returns an empty raster, but I'm not sure under what other conditions clip can not compute a raster, so I left it as returning null.

We might want to revisit this in PostGIS 2.4 to see if we can revise ST_Clip to have an option of returning a single pixel if there is a partial pixel overlap. I think right now if there is a partial pixel overlap, it doesn't return the pixel.

comment:5 by robe, 7 years ago

Resolution: fixed
Status: newclosed

fixed at r15457 for PostGIS 2.3.3

Note: See TracTickets for help on using tickets.