<paramdef><type>double precision </type> <parameter>altitude</parameter></paramdef>
<paramdef choice="opt"><type>double precision </type> <parameter>max_bright=255</parameter></paramdef>
<paramdef choice="opt"><type>double precision </type> <parameter>elevation_scale=1</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<title>Description</title>
<para>Returns the hypothetical illumination of an elevation raster band using the azimuth, altitude, brightness, and elevation scale inputs. Utilizes map algebra and applies the hill shade equation to neighboring pixels.</para>
+
+ <para>
+ If <varname>interpolate_nodata</varname> is TRUE, values for NODATA pixels from the input raster will be interpolated using <xref linkend="RT_ST_InvDistWeight4ma" /> before computing the hillshade illumination.
+ </para>
+
<para>The hill shade equation is: <programlisting>max_bright * ( (cos(zenith)*cos(slope)) + (sin(zenith)*sin(slope)*cos(azimuth - aspect)) )</programlisting>.</para>
<para>Availability: 2.0.0 </para>
- <para>Enhanced: 2.1.0 Uses <xref linkend="RT_ST_MapAlgebra" /> and runs <xref linkend="RT_ST_InvDistWeight4ma" /> before running the hillshade operation</para>
-
+ <para>Enhanced: 2.1.0 Uses <xref linkend="RT_ST_MapAlgebra" /> and added optional <varname>interpolate_nodata</varname> function parameter</para>
+
</refsection>
<refsection>
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
<paramdef><type>integer </type> <parameter>band</parameter></paramdef>
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<para>Returns the surface aspect of an elevation raster band. Utilizes map algebra and applies the aspect equation to neighboring pixels.</para>
+ <para>
+ If <varname>interpolate_nodata</varname> is TRUE, values for NODATA pixels from the input raster will be interpolated using <xref linkend="RT_ST_InvDistWeight4ma" /> before computing the surface aspect.
+ </para>
+
<para>Given the following representation of a 3x3 neighborhood of pixels:</para>
<informaltable rowsep="1" frame="all">
<para>The equation for the pixel aspect of cell E is: atan2((((G + 2H + I) - (A + 2B + C)) / 8), -(((C + 2F + I) - (A + 2D + G)) / 8))</para>
<para>Availability: 2.0.0 </para>
- <para>Enhanced: 2.1.0 Uses <xref linkend="RT_ST_MapAlgebra" /> and runs <xref linkend="RT_ST_InvDistWeight4ma" /> before running the hillshade operation</para>
+ <para>Enhanced: 2.1.0 Uses <xref linkend="RT_ST_MapAlgebra" /> and added optional <varname>interpolate_nodata</varname> function parameter</para>
</refsection>
<paramdef><type>raster </type> <parameter>rast</parameter></paramdef>
<paramdef><type>integer </type> <parameter>band</parameter></paramdef>
<paramdef><type>text </type> <parameter>pixeltype</parameter></paramdef>
+ <paramdef choice="opt"><type>boolean </type> <parameter>interpolate_nodata=FALSE</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<para>Returns the surface slope of an elevation raster band. Utilizes map algebra and applies the slope equation to neighboring pixels.</para>
+ <para>
+ If <varname>interpolate_nodata</varname> is TRUE, values for NODATA pixels from the input raster will be interpolated using <xref linkend="RT_ST_InvDistWeight4ma" /> before computing the surface slope.
+ </para>
+
<para>Given the following representation of a 3x3 neighborhood of pixels:</para>
<informaltable rowsep="1" frame="all">
<para>The equation for the pixel slope of cell E is: atan(sqrt(((c + 2f + i) - (a + 2d + g) / 8)^2 + (((g + 2h + i) - (a + 2b + c)) / 8) ^ 2))</para>
<para>Availability: 2.0.0 </para>
- <para>Enhanced: 2.1.0 Uses <xref linkend="RT_ST_MapAlgebra" /> and runs <xref linkend="RT_ST_InvDistWeight4ma" /> before running the hillshade operation</para>
+ <para>Enhanced: 2.1.0 Uses <xref linkend="RT_ST_MapAlgebra" /> and added optional <varname>interpolate_nodata</varname> function parameter</para>
</refsection>
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
-CREATE OR REPLACE FUNCTION st_slope(rast raster, band integer, pixeltype text)
+CREATE OR REPLACE FUNCTION st_slope(rast raster, band integer, pixeltype text, interpolate_nodata boolean DEFAULT FALSE)
RETURNS raster
- AS $$ SELECT ST_MapAlgebra(ARRAY[ROW(ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1), 1)]::rastbandarg[], '_st_slope4ma(double precision[][][], integer[][], text[])'::regprocedure, NULL, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text) $$
- LANGUAGE 'sql' IMMUTABLE;
+ AS $$
+ SELECT
+ CASE
+ WHEN $4 IS FALSE THEN
+ ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], '_st_slope4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text)
+ ELSE
+ ST_MapAlgebra(ARRAY[ROW(ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1), 1)]::rastbandarg[], '_st_slope4ma(double precision[][][], integer[][], text[])'::regprocedure, NULL, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text)
+ END
+ $$ LANGUAGE 'sql' IMMUTABLE;
-----------------------------------------------------------------------
-- ST_Aspect
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE;
-CREATE OR REPLACE FUNCTION st_aspect(rast raster, band integer, pixeltype text)
+CREATE OR REPLACE FUNCTION st_aspect(rast raster, band integer, pixeltype text, interpolate_nodata boolean DEFAULT FALSE)
RETURNS raster
- AS $$ SELECT ST_MapAlgebra(ARRAY[ROW(ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1), 1)]::rastbandarg[], '_st_aspect4ma(double precision[][][], integer[][], text[])'::regprocedure, NULL, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text) $$
- LANGUAGE 'sql' IMMUTABLE;
+ AS $$
+ SELECT
+ CASE
+ WHEN $4 IS FALSE THEN
+ ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], '_st_aspect4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text)
+ ELSE
+ ST_MapAlgebra(ARRAY[ROW(ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1), 1)]::rastbandarg[], '_st_aspect4ma(double precision[][][], integer[][], text[])'::regprocedure, NULL, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text)
+ END
+ $$ LANGUAGE 'sql' IMMUTABLE;
-----------------------------------------------------------------------
-- ST_HillShade
CREATE OR REPLACE FUNCTION st_hillshade(
rast raster, band integer,
pixeltype text,
- azimuth double precision, altitude double precision, max_bright double precision DEFAULT 255.0, elevation_scale double precision DEFAULT 1.0
+ azimuth double precision, altitude double precision,
+ max_bright double precision DEFAULT 255.0, elevation_scale double precision DEFAULT 1.0,
+ interpolate_nodata boolean DEFAULT FALSE
)
RETURNS RASTER
- AS $$ SELECT ST_MapAlgebra(ARRAY[ROW(ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1), 1)]::rastbandarg[], '_st_hillshade4ma(double precision[][][], integer[][], text[])'::regprocedure, NULL, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text, $4::text, $5::text, $6::text, $7::text) $$
- LANGUAGE 'sql' IMMUTABLE;
+ AS $$
+ SELECT
+ CASE
+ WHEN $8 IS FALSE THEN
+ ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], '_st_hillshade4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text, $4::text, $5::text, $6::text, $7::text)
+ ELSE
+ ST_MapAlgebra(ARRAY[ROW(ST_MapAlgebra(ARRAY[ROW($1, $2)]::rastbandarg[], 'st_invdistweight4ma(double precision[][][], integer[][], text[])'::regprocedure, $3, 'FIRST', NULL, 1, 1), 1)]::rastbandarg[], '_st_hillshade4ma(double precision[][][], integer[][], text[])'::regprocedure, NULL, 'FIRST', NULL, 1, 1, st_pixelwidth($1)::text, st_pixelheight($1)::text, $4::text, $5::text, $6::text, $7::text)
+ END
+ $$ LANGUAGE 'sql' IMMUTABLE;
-----------------------------------------------------------------------
-- Get information about the raster