Opened 12 years ago

Closed 12 years ago

#2126 closed defect (fixed)

[raster] Convex hull of an empty raster

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

Description

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

For a NULL raster…

SELECT ST_ConvexHull(NULL::raster)

 st_convexhull 
---------------
 
(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 by robe, 12 years ago

Milestone: PostGIS 2.0.2PostGIS 2.0.3

comment:2 by strk, 12 years ago

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 by dustymugs, 12 years ago

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 by pracine, 12 years ago

I tend to opt for the 3 cases.

comment:5 by dustymugs, 12 years ago

Status: newassigned

comment:6 by dustymugs, 12 years ago

Priority: mediumblocker

comment:7 by robe, 12 years ago

I'd vote for POLYGON EMPTY

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

comment:8 by dustymugs, 12 years ago

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

comment:9 by pracine, 12 years ago

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 by dustymugs, 12 years ago

Fixed for -trunk in r10810

comment:11 by dustymugs, 12 years ago

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.