pggeodb.nancy.inra.fr/db_toff - db_toff on pggeodb.nancy.inra.fr
Previous topic Chapter index Next topic

Function: st_intersection

 

 

Schema

public

 

Owner

postgres

 

Descriptions

There is no description for function st_intersection

 

Options

Option

Value

Returns

public.raster

Language

plpgsql

Parameters

rast1 public.raster

band1 integer

rast2 public.raster

band2 integer

returnband text = 'BOTH'::text

nodataval double precision [] = NULL::double precision[]

 

Definition

CREATE OR REPLACE FUNCTION public.st_intersection (
 rast1 public.raster,
 band1 integer,
 rast2 public.raster,
 band2 integer,
 returnband text = 'BOTH'::text,
 nodataval double precision [] = NULL::double precision[]
)
RETURNS public.raster AS
$span$
DECLARE

rtn raster;
_returnband text;
newnodata1 float8;
newnodata2 float8;
BEGIN
IF
ST_SRID(rast1) != ST_SRID(rast2) THEN
RAISE EXCEPTION
'The two rasters do not have the same SRID';
END IF;

newnodata1 := coalesce(nodataval[1], ST_BandNodataValue(rast1, band1), ST_MinPossibleValue(ST_BandPixelType(rast1, band1)));
newnodata2 := coalesce(nodataval[2], ST_BandNodataValue(rast2, band2), ST_MinPossibleValue(ST_BandPixelType(rast2, band2)));

_returnband := upper(returnband);

rtn := NULL;
CASE
WHEN
_returnband = 'BAND1' THEN
rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast1.val]', ST_BandPixelType(rast1, band1), 'INTERSECTION', newnodata1::text, newnodata1::text, newnodata1);
rtn := ST_SetBandNodataValue(rtn, 1, newnodata1);
WHEN _returnband = 'BAND2' THEN
rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast2.val]', ST_BandPixelType(rast2, band2), 'INTERSECTION', newnodata2::text, newnodata2::text, newnodata2);
rtn := ST_SetBandNodataValue(rtn, 1, newnodata2);
WHEN _returnband = 'BOTH' THEN
rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast1.val]', ST_BandPixelType(rast1, band1), 'INTERSECTION', newnodata1::text, newnodata1::text, newnodata1);
rtn := ST_SetBandNodataValue(rtn, 1, newnodata1);
rtn := ST_AddBand(rtn, ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast2.val]', ST_BandPixelType(rast2, band2), 'INTERSECTION', newnodata2::text, newnodata2::text, newnodata2));
rtn := ST_SetBandNodataValue(rtn, 2, newnodata2);
ELSE
RAISE EXCEPTION
'Unknown value provided for returnband: %', returnband;
RETURN NULL;
END CASE;

RETURN rtn;
END;
$span$
LANGUAGE
'plpgsql'
STABLE
CALLED ON NULL INPUT
SECURITY INVOKER
COST
100;

This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 13/03/2014 13:23
Previous topic Chapter index Next topic