Opened 6 years ago

Closed 6 years ago

#2126 closed defect (fixed)

[raster] Convex hull of an empty raster

Reported by: Bborie Park Owned by: Bborie Park
Priority: blocker Milestone: PostGIS 2.0.3
Component: raster Version: 2.0.x
Keywords: history Cc:


What is the convex hull of an empty raster (raster = NULL or width/height = zero)?

For a NULL raster...

SELECT ST_ConvexHull(NULL::raster)

(1 row)

For a raster with width or height set to zero...

SELECT ST_ConvexHull(ST_MakeEmptyRaster(1, 0, 0, 0, 1, -1, 0, 0, 0))

ERROR:  RASTER_convex_hull: Could not get raster's convex hull

Instead of an error, shouldn't the answer be NULL?

Change History (11)

comment:1 Changed 6 years ago by robe

Milestone: PostGIS 2.0.2PostGIS 2.0.3

comment:2 Changed 6 years ago by strk

Good question. For geometry ConvexHull?(EMPTY) == EMPTY. The type of EMPTY (in geometry) is taken from the type of input, but I think that's pretty arbitrary. For Raster if you take the EMPTY path I'd use POLYGON EMPTY, as I think a raster's convexhull is _always_ polygonal in other cases, is that right ?

comment:3 Changed 6 years ago by Bborie Park

For rasters, it may be that the convex hull is _NOT_ polygonal in three cases.

Case 1 and Case 2: raster width OR height is zero (but other dimension is NOT zero)

Possible Answer: LINESTRING along the non-zero dimension from upper-left

Case 3: raster width AND height is zero

Possible Answer: POINT of upper-left.

Granted, I'm just as happy returning POLYGON EMPTY as it is keeping it simple. But I wonder if raster should be as arbitrary as geometry. I wonder what ArcGIS, ENVI and ERDAS says...

comment:4 Changed 6 years ago by pracine

I tend to opt for the 3 cases.

comment:5 Changed 6 years ago by Bborie Park

Status: newassigned

comment:6 Changed 6 years ago by Bborie Park

Priority: mediumblocker

comment:7 Changed 6 years ago by robe

I'd vote for POLYGON EMPTY

what other dimension are you talking about? I thought raster spatial foot print is strictly 2D.

comment:8 Changed 6 years ago by Bborie Park

I used dimension to describe width or height of the grid. raster spatial footprint is strictly 2D (for now).

comment:9 Changed 6 years ago by pracine

We defined an empty raster by width and height = 0 but still an empty raster can have a georeference and hence being like a unidimensional point somewhere. If only one of width or height is = 0 then it is more like a line (hence bidimensional and still somewhere)...

comment:10 Changed 6 years ago by Bborie Park

Fixed for -trunk in r10810

comment:11 Changed 6 years ago by Bborie Park

Keywords: history added
Resolution: fixed
Status: assignedclosed

Fixed for 2.0 in r10817. Final solution was the three case example above (plus one case for NULL raster = NULL convex hull)

Note: See TracTickets for help on using tickets.