Name

ST_Union — 将一组栅格平铺的并集返回由1个或多个标注栏组成的单个栅格。

Synopsis

raster ST_Union(setof raster rast);

raster ST_Union(setof raster rast, unionarg[] unionargset);

raster ST_Union(setof raster rast, integer nband);

raster ST_Union(setof raster rast, text uniontype);

raster ST_Union(setof raster rast, integer nband, text uniontype);

描述

将一组栅格平铺的并集返回到至少由一个标注栏组成的单个栅格中。生成的栅格范围是整个集合的范围。在相交的情况下,结果值由 uniontype 它是以下之一:最后(默认)、第一、最小、最大、计数、总和、平均值、范围。

[Note]

为了联合栅格,它们必须都具有相同的对齐方式。使用 ST_SameAlignmentST_NotSameAlignmentReason 获取更多详细信息和帮助。解决对齐问题的一种方法是使用 ST_Resample 并使用相同的参考栅格进行对齐。

可用性:2.0.0

增强:2.1.0速度提高(完全基于C语言)。

可用性:2.1.0推出了ST_Union(RAST,unionarg)变体。

增强:2.1.0 ST_UNION(RAST)(变体1)合并所有输入栅格的所有波段。以前的PostGIS版本假定为第一个频段。

增强:2.1.0 ST_UNION(RAST,uniontype)(变体4)合并所有输入栅格的所有波段。

示例:重建单波段分块栅格切片

-- this creates a single band from first band of raster tiles
-- that form the original file system tile
SELECT filename, ST_Union(rast,1) As file_rast
FROM sometable WHERE filename IN('dem01', 'dem02') GROUP BY filename;
                    

示例:返回多波段栅格,该栅格是与几何图形相交的切片的并集

-- this creates a multi band raster collecting all the tiles that intersect a line
-- Note: In 2.0, this would have just returned a single band raster
-- , new union works on all bands by default
-- this is equivalent to unionarg: ARRAY[ROW(1, 'LAST'), ROW(2, 'LAST'), ROW(3, 'LAST')]::unionarg[]
SELECT ST_Union(rast)
FROM aerials.boston
WHERE ST_Intersects(rast,  ST_GeomFromText('LINESTRING(230486 887771, 230500 88772)',26986) );
                    

示例:返回多波段栅格,该栅格是与几何图形相交的切片的并集

在这里,如果我们只想要波段的子集或想要更改波段的顺序,则使用较长的语法

-- this creates a multi band raster collecting all the tiles that intersect a line
SELECT ST_Union(rast,ARRAY[ROW(2, 'LAST'), ROW(1, 'LAST'), ROW(3, 'LAST')]::unionarg[])
FROM aerials.boston
WHERE ST_Intersects(rast,  ST_GeomFromText('LINESTRING(230486 887771, 230500 88772)',26986) );
                    

另请参阅

工会, ST_Envelope, ST_ConvexHull, ST_Clip, ST_Union