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

Function: st_value

 

 

Schema

public

 

Owner

postgres

 

Descriptions

args: rast, band, 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 := public.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 public.ST_SRID(pt) != public.ST_SRID(rast) THEN
           RAISE EXCEPTION
'Raster and geometry do not have the same SRID';
END IF;

       x := public.ST_x(pt);
       y := public.ST_y(pt);
       RETURN public.ST_value(rast,
                       band,
                       public.ST_worldtorastercoordx(rast, x, y),
                       public.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, band, 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 26/02/2014 11:51
Previous topic Chapter index Next topic