Database Reference
In-Depth Information
SELECT
ST_AsRaster(ST_Transform(sf.geom, 3310),
r.rast) AS rast
FROM sfpoly sf
CROSS JOIN r
)
SELECT
ST_Clip(ST_Slope(r.rast, 1, cx.rast), S
T_Transform(sf.geom, 3310)) AS rast
FROM r
CROSS JOIN cx
CROSS JOIN sfpoly sf;
All spatial objects in this query are projected to California Albers ( SRID 3310 ), a
projectionwithunitsinmeters.Thisprojectioneasestheuseof ST_DWithin() to
broaden our area of interest to include the tiles within 1000 meters of San Fran-
cisco'sboundaries,whichimprovesthecomputedslopevaluesforthepixelsatthe
edgesoftheSanFranciscoboundaries.WealsousearasterizedversionofourSan
Francisco boundaries as the custom extent for restricting the computed area. After
running ST_Slope() , we clip the slope raster just to San Francisco.
We can reuse the ST_Slope() query and substitute ST_HillShade() for
ST_Slope() tocreateahillshaderastershowinghowthesunwouldilluminatethe
terrain of the SRTM raster.
WITH r AS ( -- union of filtered tiles
SELECT
ST_Transform(ST_Union(srtm.rast), 3310) AS rast
FROM srtm
JOIN sfpoly sf
ON
ST_DWithin(ST_Transform(srtm.rast::geometry, 3
310), ST_Transform(sf.geom, 3310), 1000)
), cx AS ( -- custom extent
SELECT
Search WWH ::




Custom Search