PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
PostGIS Raster : Extending PostgreSQL for The Support of ... - CoDE
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
elevation values at lidar points, only the ST_Value() function, that gives elevation values at particular<br />
geometric points, is needed.<br />
5.7.2 Intersect <strong>Raster</strong>s with Lines<br />
In the case <strong>of</strong> geometric lines, this operation is used to extract elevation values <strong>for</strong> each road<br />
segment in a road network.<br />
SELECT roadID,<br />
(ST_Intersection(geom, rast)).geom road,<br />
(ST_Intersection(geom, rast)).val elevation<br />
FROM roadNetwork, srtm<br />
WHERE ST_Intersects(geom, rast)<br />
User accesses the geometry and the value parts <strong>of</strong> the resulting set <strong>of</strong> geomval by surrounding<br />
them with parentheses and adding .geom or .val at the end <strong>of</strong> the expression.<br />
5.7.3 Intersect <strong>Raster</strong>s with Polygons<br />
Figure 5.5: Intersection <strong>of</strong> raster and roads [23].<br />
In the same way, user can extract temperature values <strong>for</strong> each polygon (circles in the following<br />
example).<br />
CREATE TABLE buff_temp AS<br />
SELECT id, (gv).geom buffer, (gv).val temp<br />
FROM (SELECT id, ST_Intersection(geom, rast) gv<br />
FROM buffers, temperature<br />
WHERE ST_Intersects(geom, rast))<br />
Figure 5.6: Intersection <strong>of</strong> raster polygons [23].<br />
<strong>The</strong>n, the result can also be used to compute the mean temperature <strong>for</strong> each polygon.<br />
CREATE TABLE result AS<br />
SELECT id,<br />
sum(ST_Area(the_geom) * val) / sum(ST_Area(the_geom)) AS meantemp<br />
69