Name

ST_Band — 将现有栅格的一个或多个波段作为新栅格返回。对于从现有栅格构建新栅格非常有用。

Synopsis

raster ST_Band(raster rast, integer[] nbands = ARRAY[1]);

raster ST_Band(raster rast, integer nband);

raster ST_Band(raster rast, text nbands, character delimiter=,);

描述

将现有栅格的一个或多个波段作为新栅格返回。用于从现有栅格构建新栅格、仅导出选定的栅格波段或重新排列栅格中的波段顺序。如果未指定标注栏或栅格中不存在任何指定标注栏,则将返回所有标注栏。在各种功能中用作辅助函数,例如用于删除波段。

[Warning]

对于 nbands 作为函数的文本变量,默认分隔符为 , 这意味着你可以要求 '1,2,3' 如果您想使用不同的分隔符,您可以这样做 ST_Band(rast, '1@2@3', '@') 。对于请求多个波段,我们强烈建议您使用此函数的数组形式,例如 ST_Band(rast, '{1,2,3}'::int[]); 自.以来 text 在未来的PostGIS版本中,可能会删除波段列表表单。

可用性:2.0.0

示例

-- Make 2 new rasters: 1 containing band 1 of dummy, second containing band 2 of dummy and then reclassified as a 2BUI
SELECT ST_NumBands(rast1) As numb1, ST_BandPixelType(rast1) As pix1,
 ST_NumBands(rast2) As numb2,  ST_BandPixelType(rast2) As pix2
FROM (
    SELECT ST_Band(rast) As rast1, ST_Reclass(ST_Band(rast,3), '100-200):1, [200-254:2', '2BUI') As rast2
        FROM dummy_rast
        WHERE rid = 2) As foo;

 numb1 | pix1 | numb2 | pix2
-------+------+-------+------
     1 | 8BUI |     1 | 2BUI
                    
-- Return bands 2 and 3. Using array cast syntax
SELECT ST_NumBands(ST_Band(rast, '{2,3}'::int[])) As num_bands
    FROM dummy_rast WHERE rid=2;

num_bands
----------
2

-- Return bands 2 and 3. Use array to define bands
SELECT ST_NumBands(ST_Band(rast, ARRAY[2,3])) As num_bands
    FROM dummy_rast
WHERE rid=2;
                    

原始(Column Rast)

dupe_band

sing_band

--Make a new raster with 2nd band of original and 1st band repeated twice,
and another with just the third band
SELECT rast, ST_Band(rast, ARRAY[2,1,1]) As dupe_band,
    ST_Band(rast, 3) As sing_band
FROM samples.than_chunked
WHERE rid=35;
                    

另请参阅

ST_AddBand, ST_NumBands, ST_Reclass, Chapter 12, 栅格参考