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.

• gvSIG plugin<br />

• MapServer through GDAL<br />

Other s<strong>of</strong>twares that do not support direct raster displaying but instead they allow displaying a<br />

vectorization <strong>of</strong> the raster. This is the case <strong>of</strong> any s<strong>of</strong>twares that are used to display vector <strong>PostGIS</strong><br />

queries such as OpenJump or ArcGIS 10.<br />

– OpenJump<br />

SELECT ST_AsBinary((ST_DumpAsPolygons(rast)).geom), (ST_DumpAsPolygons(rast)).val<br />

FROM dummy_rast<br />

WHERE rid=1;<br />

– ArcGIS 10<br />

Same as OpenJump but without ST_AsBinary():<br />

SELECT (ST_DumpAsPolygons(rast)).geom, (ST_DumpAsPolygons(rast)).val<br />

FROM dummy_rast WHERE rid=1;<br />

5.5 Edit and Compute <strong>Raster</strong>s<br />

• Set pixel value <strong>The</strong> ST_SetValue(raster, band, geometricpoint, newvalue) function returns a<br />

new raster resulting from setting the value <strong>of</strong> a given band in a given column x and row y<br />

pixel or at a pixel that intersects a particular geometric point. Band number starts at 1 and is<br />

assumed to be 1 if not specified.<br />

UPDATE dummy_rast<br />

SET rast = ST_SetValue(rast,1, ST_Point(3427927.75, 5793243.95),100)<br />

WHERE rid = 1 ;<br />

• Reclass rasters <strong>The</strong> ST_Reclass(raster, band, reclassexpression, pixeltype, nodatavalue) function<br />

creates a new raster by applying a valid <strong>PostgreSQL</strong> algebraic operation that defines a class<br />

expression on the input raster band. <strong>The</strong> band number specifies the band to be changed. If it<br />

is not specified, it is assumed to be 1. All other bands are unchanged. <strong>The</strong> new raster will have<br />

the same georeference, width and height as the original raster. Use case: convert a 16 BUI band<br />

to a 8 BUI and so on <strong>for</strong> simpler rendering.<br />

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

UPDATE dummy_rast<br />

SET reclass_rast = ST_Reclass(rast,2,’0-87:1-10, 88-100:11-15, 101-254:0-0’,<br />

’4BUI’,0)<br />

WHERE rid = 1;<br />

• Clip rasters <strong>The</strong> ST_Clip(raster, band, geometry) function returns a new raster that is clipped<br />

by an input geometry. If no band is specified all bands are returned.<br />

SELECT ST_Clip(rast, ST_Buffer(ST_Centroid(ST_Envelope(rast)), 20), false )<br />

FROM aerials.boston<br />

WHERE rid = 4;<br />

• Apply algebra operation <strong>The</strong> ST_MapAlgebraExpr(raster, band, pixeltype, expression) function<br />

creates a new one band raster by applying a valid <strong>PostgreSQL</strong> algebraic operation on the input<br />

raster band. Band 1 is assumed if no band is specified. <strong>The</strong> new raster will have the same<br />

georeference, width and height as the original raster but will only have one band. If pixeltype<br />

is given, then the new raster will have a band <strong>of</strong> that pixeltype. If pixeltype is passed NULL,<br />

then the new raster band will have the same pixeltype as the input rast band.<br />

66

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

Saved successfully!

Ooh no, something went wrong!