Schema
Owner
postgres
Descriptions
args: rast, options=NULL - Return the raster tile selected bands as a single portable network graphics (PNG) image (byte array). If 1, 3, or 4 bands in raster and no bands are specified, then all bands are used. If more 2 or more than 4 bands and no bands specified, then only band 1 is used. Bands are mapped to RGB or RGBA space.
Options
Option | Value |
---|---|
Returns |
bytea |
Language |
|
Parameters |
rast public.raster options text [] = NULL::text[] |
Definition
CREATE OR REPLACE FUNCTION public.st_aspng (
rast public.raster,
options text [] = NULL::text[]
)
RETURNS bytea AS
$span$
DECLARE
rast2 raster;
num_bands int;
i int;
pt text;
BEGIN
IF rast IS NULL THEN
RETURN NULL;
END IF;
num_bands := st_numbands($1);
-- PNG allows 1, 3 or 4 bands
IF num_bands <> 1 AND num_bands <> 3 AND num_bands <> 4 THEN
RAISE NOTICE 'The PNG format only permits one, three or four bands. The first band will be used.';
rast2 := st_band($1, ARRAY[1]);
num_bands := st_numbands(rast2);
ELSE
rast2 := rast;
END IF;
-- PNG only supports 8BUI and 16BUI pixeltype
FOR i IN 1..num_bands LOOP
pt = st_bandpixeltype(rast, i);
IF pt != '8BUI' AND pt != '16BUI' THEN
RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types.', i;
END IF;
END LOOP;
RETURN st_asgdalraster(rast2, 'PNG', $2, NULL);
END;
$span$
LANGUAGE 'plpgsql'
IMMUTABLE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
COMMENT ON FUNCTION public.st_aspng(rast public.raster, options text [])
IS 'args: rast, options=NULL - Return the raster tile selected bands as a single portable network graphics (PNG) image (byte array). If 1, 3, or 4 bands in raster and no bands are specified, then all bands are used. If more 2 or more than 4 bands and no bands specified, then only band 1 is used. Bands are mapped to RGB or RGBA space.';
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 07/12/2018 13:23 |