名称

ST_SetBandIndex — 更新out-db band的external band编号

大纲

raster ST_SetBandIndex(raster rast, integer band, integer outdbindex, boolean force=false);

Description

更新 out-db band 的外部 band 编号。 这不会触及与 out-db band 关联的外部栅格文件

[注意]

如果force设置为true,则不会进行任何测试来确保外部栅格文件和PostGIS栅格之间的兼容性(例如对齐、像素支持)。 此模式适用于在外部栅格文件中移动波段的情况。

[注意]

在内部,此方法将索引band处的 PostGIS 栅格波段替换为新波段,而不是更新现有的路径信息。

可用性:2.5.0

示例

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
    1 AS query,
    bandnum,
    regexp_replace(path, '^.*/', '') AS path,
    outdbbandnum
FROM ST_BandMetaData(
    (SELECT rast FROM foo),
    ARRAY[1, 3, 2]::int[]
) AS metadata
UNION ALL
SELECT
    2, bandnum,
    regexp_replace(path, '^.*/', ''),
    outdbbandnum
FROM ST_BandMetaData((
        SELECT
            ST_SetBandIndex(rast,
                2,
                1
            ) AS rast
        FROM foo
    ),
    ARRAY[1, 3, 2]::int[]
) AS metadata
ORDER BY 1, 2;

In the second result set, band 2 still points at the same file but now reads external band 1.

栅格输出
query | bandnum | path          | outdbbandnum
-------+---------+---------------+--------------
     1 |       1 | Projected.tif |            1
     1 |       2 | Projected.tif |            2
     1 |       3 | Projected.tif |            3
     2 |       1 | Projected.tif |            1
     2 |       2 | Projected.tif |            1
     2 |       3 | Projected.tif |            3