名称

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

大纲

geometry ST_ConvexHull(raster rast);

Description

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

[注意]

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

示例

See doc/development/internals/raster-affine.md for the scale, skew, and rotation terms that make the convex hull and envelope differ for skewed rasters.

For regular non-skewed rasters, the envelope and convex hull are more or less the same.

Code
SELECT ST_ConvexHull(rast) As convhull, 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.

Code
SELECT ST_ConvexHull(rast) As convhull, 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))