<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>raster <function>ST_HillShade</function></funcdef>
- <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
- <paramdef choice="opt"><type>integer </type> <parameter>band=1</parameter></paramdef>
- <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
- <paramdef choice="opt"><type>double precision </type> <parameter>azimuth=315</parameter></paramdef>
- <paramdef choice="opt"><type>double precision </type> <parameter>altitude=45</parameter></paramdef>
- <paramdef choice="opt"><type>double precision </type> <parameter>max_bright=255</parameter></paramdef>
- <paramdef choice="opt"><type>double precision </type> <parameter>scale=1.0</parameter></paramdef>
- <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
+ <funcdef>raster <function>ST_HillShade</function></funcdef>
+ <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+ <paramdef choice="opt"><type>integer </type> <parameter>band=1</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>azimuth=315</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>altitude=45</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>max_bright=255</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>scale=1.0</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>raster <function>ST_HillShade</function></funcdef>
+ <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+ <paramdef><type>integer </type> <parameter>band</parameter></paramdef>
+ <paramdef><type>raster </type> <parameter>customextent</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>azimuth=315</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>altitude=45</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>max_bright=255</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>scale=1.0</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
</refsection>
<refsection>
- <title>Examples</title>
+ <title>Examples: Variant 1</title>
<programlisting>
WITH foo AS (
SELECT ST_SetValues(
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>raster <function>ST_Aspect</function></funcdef>
- <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
- <paramdef choice="opt"><type>integer </type> <parameter>band=1</parameter></paramdef>
- <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
- <paramdef choice="opt"><type>text </type> <parameter>measurement=DEGREES</parameter></paramdef>
- <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
+ <funcdef>raster <function>ST_Aspect</function></funcdef>
+ <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+ <paramdef choice="opt"><type>integer </type> <parameter>band=1</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>units=DEGREES</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>raster <function>ST_Aspect</function></funcdef>
+ <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+ <paramdef><type>integer </type> <parameter>band</parameter></paramdef>
+ <paramdef><type>raster </type> <parameter>customextent</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>units=DEGREES</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<para>Returns the aspect (in degrees by default) of an elevation raster band. Utilizes map algebra and applies the aspect equation to neighboring pixels.</para>
<para>
- <varname>measurement</varname> indicates the units of the aspect. Possible values are: RADIANS, DEGREES (default).
+ <varname>units</varname> indicates the units of the aspect. Possible values are: RADIANS, DEGREES (default).
</para>
<para>
- When <varname>measurement</varname> = RADIANS, values are between 0 and 2π radians measured clockwise from North.
+ When <varname>units</varname> = RADIANS, values are between 0 and 2π radians measured clockwise from North.
</para>
<para>
- When <varname>measurement</varname> = DEGREES, values are between 0 and 360 degrees measured clockwise from North.
+ When <varname>units</varname> = DEGREES, values are between 0 and 360 degrees measured clockwise from North.
</para>
<para>
</refsection>
<refsection>
- <title>Examples</title>
+ <title>Examples: Variant 1</title>
<programlisting>
WITH foo AS (
SELECT ST_SetValues(
<refsynopsisdiv>
<funcsynopsis>
<funcprototype>
- <funcdef>raster <function>ST_Slope</function></funcdef>
- <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
- <paramdef choice="opt"><type>integer </type> <parameter>nband=1</parameter></paramdef>
- <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
- <paramdef choice="opt"><type>text </type> <parameter>measurement=DEGREES</parameter></paramdef>
- <paramdef choice="opt"><type>double precision </type> <parameter>scale=1.0</parameter></paramdef>
- <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
+ <funcdef>raster <function>ST_Slope</function></funcdef>
+ <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+ <paramdef choice="opt"><type>integer </type> <parameter>nband=1</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>units=DEGREES</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>scale=1.0</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
+ </funcprototype>
+
+ <funcprototype>
+ <funcdef>raster <function>ST_Slope</function></funcdef>
+ <paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
+ <paramdef><type>integer </type> <parameter>nband</parameter></paramdef>
+ <paramdef><type>raster </type> <parameter>customextent</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>pixeltype=32BF</parameter></paramdef>
+ <paramdef choice="opt"><type>text </type> <parameter>units=DEGREES</parameter></paramdef>
+ <paramdef choice="opt"><type>double precision </type> <parameter>scale=1.0</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<para>Returns the slope (in degrees by default) of an elevation raster band. Utilizes map algebra and applies the slope equation to neighboring pixels.</para>
<para>
- <varname>measurement</varname> indicates the units of the slope. Possible values are: RADIANS, DEGREES (default), PERCENT.
+ <varname>units</varname> indicates the units of the slope. Possible values are: RADIANS, DEGREES (default), PERCENT.
</para>
<para>
</note>
<para>Availability: 2.0.0 </para>
- <para>Enhanced: 2.1.0 Uses ST_MapAlgebra() and added optional <varname>measurement</varname>, <varname>scale</varname>, <varname>interpolate_nodata</varname> function parameters</para>
+ <para>Enhanced: 2.1.0 Uses ST_MapAlgebra() and added optional <varname>units</varname>, <varname>scale</varname>, <varname>interpolate_nodata</varname> function parameters</para>
<para>Changed: 2.1.0 In prior versions, return values were in radians. Now, return values default to degrees</para>
</refsection>
<refsection>
- <title>Examples</title>
+ <title>Examples: Variant 1</title>
<programlisting>
WITH foo AS (
SELECT ST_SetValues(
_pixheight double precision;
_width double precision;
_height double precision;
- _measure text;
+ _units text;
_scale double precision;
dz_dx double precision;
_pixheight := userargs[2]::double precision;
_width := userargs[3]::double precision;
_height := userargs[4]::double precision;
- _measure := userargs[5];
+ _units := userargs[5];
_scale := userargs[6]::double precision;
/* ArcGIS returns values for edge pixels
slope := sqrt(dz_dx * dz_dx + dz_dy * dz_dy) / (8 * _scale);
-- output depends on user preference
- CASE substring(upper(trim(leading from _measure)) for 3)
+ CASE substring(upper(trim(leading from _units)) for 3)
-- percentages
WHEN 'PER' THEN
slope := 100.0 * slope;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_slope(
- rast raster, nband integer DEFAULT 1,
- pixeltype text DEFAULT '32BF', measurement text DEFAULT 'DEGREES',
+ rast raster, nband integer,
+ customextent raster,
+ pixeltype text DEFAULT '32BF', units text DEFAULT 'DEGREES',
scale double precision DEFAULT 1.0, interpolate_nodata boolean DEFAULT FALSE
)
RETURNS raster
_pixheight double precision;
_width integer;
_height integer;
+ _customextent raster;
+ _extenttype text;
BEGIN
+ _customextent := customextent;
+ IF _customextent IS NULL THEN
+ _extenttype := 'FIRST';
+ ELSE
+ _extenttype := 'CUSTOM';
+ END IF;
+
IF interpolate_nodata IS TRUE THEN
- _rast := ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1);
+ _rast := ST_MapAlgebra(
+ ARRAY[ROW(rast, nband)]::rastbandarg[],
+ 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ pixeltype,
+ 'FIRST', NULL,
+ 1, 1
+ );
_nband := 1;
_pixtype := NULL;
ELSE
ARRAY[ROW(_rast, _nband)]::rastbandarg[],
'_st_slope4ma(double precision[][][], integer[][], text[])'::regprocedure,
_pixtype,
- 'FIRST', NULL,
+ _extenttype, _customextent,
1, 1,
_pixwidth::text, _pixheight::text,
_width::text, _height::text,
- $4::text, $5::text
+ units::text, scale::text
);
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
+CREATE OR REPLACE FUNCTION st_slope(
+ rast raster, nband integer DEFAULT 1,
+ pixeltype text DEFAULT '32BF', units text DEFAULT 'DEGREES',
+ scale double precision DEFAULT 1.0, interpolate_nodata boolean DEFAULT FALSE
+)
+ RETURNS raster
+ AS $$ SELECT st_slope($1, $2, NULL::raster, $3, $4, $5, $6) $$
+ LANGUAGE 'sql' IMMUTABLE;
+
-----------------------------------------------------------------------
-- ST_Aspect
-- http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=How%20Hillshade%20works
_width double precision;
_height double precision;
- _measure text;
+ _units text;
dz_dx double precision;
dz_dy double precision;
_width := userargs[1]::double precision;
_height := userargs[2]::double precision;
- _measure := userargs[3];
+ _units := userargs[3];
/* ArcGIS returns values for edge pixels
-- check that pixel is not edge pixel
END IF;
-- output depends on user preference
- CASE substring(upper(trim(leading from _measure)) for 3)
+ CASE substring(upper(trim(leading from _units)) for 3)
-- radians
WHEN 'rad' THEN
RETURN aspect;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_aspect(
- rast raster, nband integer DEFAULT 1,
- pixeltype text DEFAULT '32BF', measurement text DEFAULT 'DEGREES',
+ rast raster, nband integer,
+ customextent raster,
+ pixeltype text DEFAULT '32BF', units text DEFAULT 'DEGREES',
interpolate_nodata boolean DEFAULT FALSE
)
RETURNS raster
_pixtype text;
_width integer;
_height integer;
+ _customextent raster;
+ _extenttype text;
BEGIN
+ _customextent := customextent;
+ IF _customextent IS NULL THEN
+ _extenttype := 'FIRST';
+ ELSE
+ _extenttype := 'CUSTOM';
+ END IF;
+
IF interpolate_nodata IS TRUE THEN
- _rast := ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1);
+ _rast := ST_MapAlgebra(
+ ARRAY[ROW(rast, nband)]::rastbandarg[],
+ 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ pixeltype,
+ 'FIRST', NULL,
+ 1, 1
+ );
_nband := 1;
_pixtype := NULL;
ELSE
ARRAY[ROW(_rast, _nband)]::rastbandarg[],
'_st_aspect4ma(double precision[][][], integer[][], text[])'::regprocedure,
_pixtype,
- 'FIRST', NULL,
+ _extenttype, _customextent,
1, 1,
_width::text, _height::text,
- $4::text
+ units::text
);
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
+CREATE OR REPLACE FUNCTION st_aspect(
+ rast raster, nband integer DEFAULT 1,
+ pixeltype text DEFAULT '32BF', units text DEFAULT 'DEGREES',
+ interpolate_nodata boolean DEFAULT FALSE
+)
+ RETURNS raster
+ AS $$ SELECT st_aspect($1, $2, NULL::raster, $3, $4, $5) $$
+ LANGUAGE 'sql' IMMUTABLE;
+
-----------------------------------------------------------------------
-- ST_HillShade
-- http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=How%20Hillshade%20works
$$ LANGUAGE 'plpgsql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_hillshade(
- rast raster, nband integer DEFAULT 1,
+ rast raster, nband integer,
+ customextent raster,
pixeltype text DEFAULT '32BF',
azimuth double precision DEFAULT 315.0, altitude double precision DEFAULT 45.0,
max_bright double precision DEFAULT 255.0, scale double precision DEFAULT 1.0,
_pixheight double precision;
_width integer;
_height integer;
+ _customextent raster;
+ _extenttype text;
BEGIN
+ _customextent := customextent;
+ IF _customextent IS NULL THEN
+ _extenttype := 'FIRST';
+ ELSE
+ _extenttype := 'CUSTOM';
+ END IF;
+
IF interpolate_nodata IS TRUE THEN
- _rast := ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1);
+ _rast := ST_MapAlgebra(
+ ARRAY[ROW(rast, nband)]::rastbandarg[],
+ 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure,
+ pixeltype,
+ 'FIRST', NULL,
+ 1, 1
+ );
_nband := 1;
_pixtype := NULL;
ELSE
ARRAY[ROW(_rast, _nband)]::rastbandarg[],
'_st_hillshade4ma(double precision[][][], integer[][], text[])'::regprocedure,
_pixtype,
- 'FIRST', NULL,
+ _extenttype, _customextent,
1, 1,
_pixwidth::text, _pixheight::text,
_width::text, _height::text,
- $4::text, $5::text,
- $6::text, $7::text
+ $5::text, $6::text,
+ $7::text, $8::text
);
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
+CREATE OR REPLACE FUNCTION st_hillshade(
+ rast raster, nband integer DEFAULT 1,
+ pixeltype text DEFAULT '32BF',
+ azimuth double precision DEFAULT 315.0, altitude double precision DEFAULT 45.0,
+ max_bright double precision DEFAULT 255.0, scale double precision DEFAULT 1.0,
+ interpolate_nodata boolean DEFAULT FALSE
+)
+ RETURNS RASTER
+ AS $$ SELECT st_hillshade($1, $2, NULL::raster, $3, $4, $5, $6, $7, $8) $$
+ LANGUAGE 'sql' IMMUTABLE;
+
-----------------------------------------------------------------------
-- Get information about the raster
-----------------------------------------------------------------------