]> granicus.if.org Git - postgis/commitdiff
Added optional interpolate_nodata flag as function parameter to ST_HillShade,
authorBborie Park <bkpark at ucdavis.edu>
Tue, 16 Oct 2012 20:59:06 +0000 (20:59 +0000)
committerBborie Park <bkpark at ucdavis.edu>
Tue, 16 Oct 2012 20:59:06 +0000 (20:59 +0000)
ST_Aspect and ST_Slope.

git-svn-id: http://svn.osgeo.org/postgis/trunk@10445 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
doc/reference_raster.xml
raster/rt_pg/rtpostgis.sql.in.c
raster/rt_pg/rtpostgis_drop.sql.in.c

diff --git a/NEWS b/NEWS
index 539f227d787beef12fa798f47fc7e1797a7bb5ff..01830144510e29d90a81b3900a531d2248c50ebc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -52,6 +52,8 @@ PostGIS 2.1.0
   - #2006, better support of ST_Area(geography) over poles and dateline
   - TopologySummary output now includes unregistered layers and a count
     of missing TopoGeometry objects from their natural layer.
+  - ST_HillShade(), ST_Aspect() and ST_Slope() have one new optional parameter to
+    interpolate NODATA pixels before running the operation.
 
 * Fixes *
 
index 13cd542cf8bb073171cf40b7ce57ac1608c0e0ba..c15b06aad47d938ef1ed97c1eb7d9a8bfb12ff57 100644 (file)
@@ -7243,6 +7243,7 @@ FROM dummy_rast;
                                        <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>
@@ -7251,10 +7252,15 @@ FROM dummy_rast;
                                <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>
@@ -7283,6 +7289,7 @@ FROM dummy_rast;
                                        <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>
@@ -7292,6 +7299,10 @@ FROM dummy_rast;
                                
                                <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">
@@ -7319,7 +7330,7 @@ FROM dummy_rast;
                 <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>
                                
@@ -7349,6 +7360,7 @@ FROM dummy_rast;
                                        <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>
@@ -7358,6 +7370,10 @@ FROM dummy_rast;
                                
                                <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">
@@ -7385,7 +7401,7 @@ FROM dummy_rast;
                 <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>
                                
index 820e1567597cfc9b39feef8a7978cc1cfeded4bf..1d496a557f087ee88ea14ac97cd6acbd4f9d4f11 100644 (file)
@@ -3466,10 +3466,17 @@ CREATE OR REPLACE FUNCTION _st_slope4ma(value double precision[][][], pos intege
        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
@@ -3533,10 +3540,17 @@ CREATE OR REPLACE FUNCTION _st_aspect4ma(value double precision[][][], pos integ
        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
@@ -3617,11 +3631,20 @@ CREATE OR REPLACE FUNCTION _st_hillshade4ma(value double precision[][][], pos in
 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
index 678439a765e91017d9cf424a97339f6da77efdd5..fbcadb33475bead1d94e2382d0730e7bed4c86dd 100644 (file)
@@ -435,3 +435,8 @@ DROP FUNCTION IF EXISTS _st_contains(geometry, raster, integer);
 
 -- function signature changed
 DROP FUNCTION IF EXISTS st_addband(raster, raster[], integer);
+
+-- function signatures changed
+DROP FUNCTION IF EXISTS st_slope(raster, integer, text);
+DROP FUNCTION IF EXISTS st_aspect(raster, integer, text);
+DROP FUNCTION IF EXISTS st_hillshade(raster, integer, text, float, float, float, float);