Name

ST_SetBandPath — Update the external path and band number of an out-db band

Synopsis

raster ST_SetBandPath(raster rast, integer band, text outdbpath, integer outdbindex, boolean force=false);

Description

Updates an out-db band's external raster file path and external band number.

[Note]

If force is set to true, no tests are done to ensure compatibility (e.g. alignment, pixel support) between the external raster file and the PostGIS raster. This mode is intended for file system changes where the external raster resides.

Availability: 2.5.0

Examples

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_SetBandPath(rast,
                2,
                '/home/pele/devel/geo/postgis-git/raster/test/regress/loader/Projected2.tif',
                1
            ) AS rast
        FROM foo
    ),
    ARRAY[1, 3, 2]::int[]
) AS metadata
ORDER BY 1, 2;

In the second result set, band 2 now points at Projected2.tif and uses out-db band 1.

Output
 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 | Projected2.tif |            1
     2 |       3 | Projected.tif  |            3