名称

ST_BandMetaData — 返回特定栅格波段的基本元数据。 如果未指定,则假定波段编号为 1。

大纲

(1) record ST_BandMetaData(raster rast, integer band=1);

(2) record ST_BandMetaData(raster rast, integer[] band);

Description

返回有关栅格波段的基本元数据。 返回的列:pixeltype、nodatavalue、isoutdb、path、outdbbandnum、filesize、filetimestamp。

[注意]

如果栅格不包含波段,则会引发错误。

[注意]

如果 band 没有 NODATA 值,则 nodatavalue 为 NULL。

[注意]

如果 isoutdb 为 False,则路径、outdbbandnum、文件大小和文件时间戳为 NULL。 如果禁用 outdb 访问,则文件大小和文件时间戳也将为 NULL。

增强:2.5.0 包括 outdbbandnum文件大小文件时间戳 for outdb 栅格。

示例

Variant 1.

Code
SELECT
    rid,
    (foo.md).*
FROM (
    SELECT
        rid,
        ST_BandMetaData(rast, 1) AS md
    FROM dummy_rast
    WHERE rid=2
) As foo;
栅格输出
rid | pixeltype | nodatavalue | isoutdb | path | outdbbandnum
-----+-----------+-------------+---------+------+--------------
   2 | 8BUI      |           0 | f       |      |
(1 row)
                

Variant 2.

Code
WITH foo AS (
    SELECT
        ST_AddBand(NULL::raster, '/home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected.tif', NULL::int[]) AS rast
)
SELECT
    bandnum,
    pixeltype,
    isoutdb,
    regexp_replace(path, '^.*/', '') AS file,
    outdbbandnum
FROM ST_BandMetaData((SELECT rast FROM foo),
    ARRAY[1, 3, 2]::int[]
);
栅格输出
bandnum | pixeltype | isoutdb |     file      | outdbbandnum
---------+-----------+---------+---------------+--------------
       1 | 8BUI      | t       | Projected.tif |            1
       3 | 8BUI      | t       | Projected.tif |            3
       2 | 8BUI      | t       | Projected.tif |            2