[postgis-devel] [PostGIS] #2077: [raster] ST_Hillshade output can be wrong

PostGIS trac at osgeo.org
Fri Nov 2 10:07:56 PDT 2012


#2077: [raster] ST_Hillshade output can be wrong
-----------------------+----------------------------------------------------
 Reporter:  dustymugs  |       Owner:  dustymugs    
     Type:  defect     |      Status:  new          
 Priority:  medium     |   Milestone:  PostGIS 2.0.2
Component:  raster     |     Version:  2.0.x        
 Keywords:             |  
-----------------------+----------------------------------------------------
 The following doesn't return the correct answers.

 {{{
 WITH foo AS (
         SELECT
                 ST_SetValue(
                         ST_SetValue(
                                 ST_SetValue(
                 ST_SetValue(
                         ST_SetValue(
                                 ST_SetValue(
                 ST_SetValue(
                         ST_SetValue(
                                 ST_SetValue(
                                         ST_AddBand(ST_MakeEmptyRaster(5,
 5, 0, 0, 1, -1, 0, 0, 0), 1, '32BF', 1, -9999),
                                         1, 2, 2, 2
                                 ),
                                 1, 3, 2, 2
                         ),
                         1, 4, 2, 2
                 ),
                                         1, 2, 3, 2
                                 ),
                                 1, 3, 3, 3
                         ),
                         1, 4, 3, 2
                 ),
                                         1, 2, 4, 2
                                 ),
                                 1, 3, 4, 2
                         ),
                         1, 4, 4, 2
                 ) AS rast
 ), bar AS (
         SELECT
                 ST_Slope(rast, 1, '32BF') AS slope,
                 ST_Aspect(rast, 1, '32BF') AS aspect,
                 ST_Hillshade(rast, 1, '32BF', 1.75 * pi(), pi() / 4) AS
 hillshade
         FROM foo
 )
 SELECT
         x, y, val
 FROM (
         SELECT
                 (ST_PixelAsPolygons(hillshade)).*
         FROM bar
 ) baz
 }}}

 results in

 {{{
  x | y |       val
 ---+---+------------------
  1 | 1 |
  1 | 2 |
  1 | 3 |
  1 | 4 |
  1 | 5 |
  2 | 1 |
  2 | 2 |  251.32763671875
  2 | 3 | 220.749786376953
  2 | 4 | 147.224319458008
  2 | 5 |
  3 | 1 |
  3 | 2 | 220.749786376953
  3 | 3 | 180.312225341797
  3 | 4 | 67.7497863769531
  3 | 5 |
  4 | 1 |
  4 | 2 | 147.224319458008
  4 | 3 | 220.749786376953
  4 | 4 | 43.1210060119629
  4 | 5 |
  5 | 1 |
  5 | 2 |
  5 | 3 |
  5 | 4 |
  5 | 5 |
 (25 rows)
 }}}

 The value for 4x3 is incorrect.

 The equivalent in ArcGIS Spatial Analyst's Hillshade tool with azimuth =
 315 degrees and altitude = 45 degrees on the attached raster (same as what
 is built in sql) looks like

 {{{
 NUL NUL NUL NUL NUL
 NUL 251 220 147 NUL
 NUL 220 180  67 NUL
 NUL 147  67  43 NUL
 NUL NUL NUL NUL NUL
 }}}

 The cell 4x3 should be 67, NOT 220.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2077>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list