March 2018
Beginner to intermediate
584 pages
14h 31m
English
Let's generate a slope raster from a subset of our SRTM raster tiles using ST_Slope(). A slope raster computes the rate of elevation change from one pixel to a neighboring pixel:
WITH r AS ( -- union of filtered tiles
SELECT ST_Transform(ST_Union(srtm.rast), 3310) AS rast
FROM chp05.srtm
JOIN chp05.sfpoly sf ON ST_DWithin(ST_Transform(srtm.rast::geometry,
3310), ST_Transform(sf.geom, 3310), 1000)),
cx AS ( -- custom extent
SELECT ST_AsRaster(ST_Transform(sf.geom, 3310), r.rast) AS rast
FROM chp05.sfpoly sf CROSS JOIN r
)
SELECT ST_Clip(ST_Slope(r.rast, 1, cx.rast), ST_Transform(sf.geom, 3310)) AS rast FROM r
CROSS JOIN cx
CROSS JOIN chp05.sfpoly sf;
All spatial objects in this query are projected to California Albers (SRID ...