Opened 12 years ago
Closed 12 years ago
#2077 closed defect (fixed)
[raster] ST_Hillshade output can be wrong
Reported by: | dustymugs | Owned by: | dustymugs |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.2 |
Component: | raster | Version: | 2.0.x |
Keywords: | history | Cc: |
Description
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.
Attachments (5)
Change History (10)
by , 12 years ago
comment:2 by , 12 years ago
For -trunk, better to use the following query
WITH foo AS ( SELECT ST_SetValues( ST_AddBand(ST_MakeEmptyRaster(5, 5, 0, 0, 1, -1, 0, 0, 0), 1, '32BF', 0, -9999), 1, 1, 1, ARRAY[ [1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1] ]::double precision[][] ) AS rast ), bar AS ( SELECT ST_Slope(rast, 1, '32BF') AS slope, ST_Aspect(rast, 1, '32BF') AS aspect, ST_Hillshade(rast, 1, '32BF', 315, 45) AS hillshade FROM foo ) SELECT ST_DumpValues(slope) FROM bar
comment:5 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Oops. Forgot to resolve ticket.
Note:
See TracTickets
for help on using tickets.
source raster