ST_Union — 返回一組網格圖磚的聯集,成為一個由一或多個波段組成的單一網格。
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
定義,uniontype
是以下其中一個:LAST(預設)、FIRST、MIN、MAX、COUNT、SUM、MEAN、RANGE。
![]() |
|
為了使網格可以進行聯集,它們必須都具有相同的對齊方式。有關更多詳細資訊和幫助,請使用 ST_SameAlignment 和 ST_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) );