Name

ST_ConvexHull — 返回栅格的凸包几何形状,包括等于 BandNoDataValue 的像素值。 对于规则形状和非倾斜栅格,这给出与 ST_Envelope 相同的结果,因此仅对不规则形状或倾斜栅格有用。

Synopsis

geometry ST_ConvexHull(raster rast);

描述

返回栅格的凸包几何形状,包括 NoDataBandValue 带像素。 对于规则形状和非倾斜栅格,这或多或少会产生与 ST_Envelope 相同的结果,因此仅对不规则形状或倾斜栅格有用。

[Note]

ST_Envelope 将坐标向下取整,因此在栅格周围添加了一小部分缓冲区,因此结果与不对坐标向下取整的 ST_ConvexHull 稍有不同。

示例

有关此图,请参阅 PostGIS Raster Specific

-- Note envelope and convexhull are more or less the same
SELECT ST_AsText(ST_ConvexHull(rast)) As convhull,
    ST_AsText(ST_Envelope(rast)) As env
FROM dummy_rast WHERE rid=1;

                        convhull                        |                env
--------------------------------------------------------+------------------------------------
 POLYGON((0.5 0.5,20.5 0.5,20.5 60.5,0.5 60.5,0.5 0.5)) | POLYGON((0 0,20 0,20 60,0 60,0 0))
                
-- now we skew the raster
-- note how the convex hull and envelope are now different
SELECT ST_AsText(ST_ConvexHull(rast)) As convhull,
    ST_AsText(ST_Envelope(rast)) As env
FROM (SELECT ST_SetRotation(rast, 0.1, 0.1) As rast
    FROM dummy_rast WHERE rid=1) As foo;

                        convhull                        |                env
--------------------------------------------------------+------------------------------------
 POLYGON((0.5 0.5,20.5 1.5,22.5 61.5,2.5 60.5,0.5 0.5)) | POLYGON((0 0,22 0,22 61,0 61,0 0))