13.07.2013 Views

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

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 5.2: Clipping raster effect [17].<br />

ALTER TABLE dummy_rast ADD COLUMN map_rast raster;<br />

UPDATE dummy_rast SET map_rast = ST_MapAlgebraExpr(rast,NULL,<br />

’CASE WHEN rast < 0 THEN rast+10 ELSE NULL END’)<br />

WHERE rid = 1;<br />

Figure 5.3: Algebra operation on rasters [23].<br />

5.6 Convert <strong>Raster</strong>s to GDAL Format<br />

5.6.1 <strong>Raster</strong> to TIFF File<br />

<strong>The</strong> ST_AsTIFF(raster, numberbands, compression) function returns the selected raster bands as a<br />

single TIFF image (byte array). If no band is specified, it will try to use all bands. Where:<br />

– numberbands: an array <strong>of</strong> bands used to export (max is 3 bands). <strong>The</strong> order <strong>of</strong> the bands is<br />

RGB. For example, ARRAY[3,2,1] maps band 3 to Red, band 2 to green and band 1 to blue.<br />

– compression: a compression type such as JPEG90 (or some other percent), LZW, JPEG or<br />

DEFLATE9.<br />

SELECT ST_AsTIFF(rast, ’JPEG90’) As rasttiff<br />

FROM dummy_rast<br />

WHERE rid=1;<br />

5.6.2 <strong>Raster</strong> to JPEG File<br />

<strong>The</strong> (ST_AsJPEG(raster, band/numberbands, quality) function returns the selected raster bands as<br />

a single JPEG image (byte array). Where:<br />

– band: a number that specifies a band <strong>for</strong> single band export.<br />

– numberbands: an array <strong>of</strong> bands used to export (max is 3 bands). <strong>The</strong> order <strong>of</strong> the bands is<br />

RGB. If more than 3 bands are specified, then only the first band is used. If only 3 bands are specified,<br />

then all 3 bands are mapped to RGB. For example, ARRAY[3,2,1] maps band 3 to Red, band 2 to<br />

green and band 1 to blue. If both band and numberbands are specified, band 1 is used by default.<br />

– quality: a number ranged from 0 to 100. Default is 75.<br />

67

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!