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

Function: st_value

 

 

Schema

public

 

Owner

postgres

 

Descriptions

args: rast, bandnum, pt, exclude_nodata_value=true - Returns the value of a given band in a given columnx, rowy pixel or at a particular geometric point. Band numbers start at 1 and assumed to be 1 if not specified. If exclude_nodata_value is set to false, then all pixels include nodata pixels are considered to intersect and return value. If exclude_nodata_value is not passed in then reads it from metadata of raster.

 

Options

Option

Value

Returns

double precision

Language

plpgsql

Parameters

rast public.raster

band integer

pt public.geometry

exclude_nodata_value boolean = true

 

Definition

CREATE OR REPLACE FUNCTION public.st_value (
 rast public.raster,
 band integer,
 pt public.geometry,
 exclude_nodata_value boolean = true
)
RETURNS double precision AS
$span$
   DECLARE

       x float8;
       y float8;
       gtype text;
   BEGIN
       gtype := st_geometrytype(pt);
       IF ( gtype != 'ST_Point' ) THEN
           RAISE EXCEPTION
'Attempting to get the value of a pixel with a non-point geometry';
       END IF;

IF ST_SRID(pt) != ST_SRID(rast) THEN
           RAISE EXCEPTION
'Raster and geometry do not have the same SRID';
END IF;

       x := st_x(pt);
       y := st_y(pt);
       RETURN st_value(rast,
                       band,
                       st_worldtorastercoordx(rast, x, y),
                       st_worldtorastercoordy(rast, x, y),
                       exclude_nodata_value);
   END;
$span$
LANGUAGE
'plpgsql'
IMMUTABLE
RETURNS NULL ON NULL INPUT
SECURITY INVOKER
COST
100;

COMMENT ON FUNCTION public.st_value(rast public.raster, band integer, pt public.geometry, exclude_nodata_value boolean)
IS 'args: rast, bandnum, pt, exclude_nodata_value=true - Returns the value of a given band in a given columnx, rowy pixel or at a particular geometric point. Band numbers start at 1 and assumed to be 1 if not specified. If exclude_nodata_value is set to false, then all pixels include nodata pixels are considered to intersect and return value. If exclude_nodata_value is not passed in then reads it from metadata of raster.';

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