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.
SELECT rast As origin, ST_Resample(rast,100,100) As reduce_100<br />
FROM dummy_rast;<br />
With this query, all rasters will be resampled into new dimension 100x100 using NearestNeighbor<br />
algorith by default.<br />
• Rescale rasters Rescaling a raster corresponds to resample a raster by adjusting its scale (or pixel<br />
size). New pixel values are computed using the NearestNeighbor, Bilinear, Cubic, CubicSpline<br />
or Lanczos resampling algorithm. Default is NearestNeighbor. <strong>The</strong> following example rescales<br />
rasters to a pixel size <strong>of</strong> 0.0015 using ST_Rescale(raster, scalexy, algorithm).<br />
SELECT ST_Rescale(rast,0.0015)<br />
FROM dummy_rast;<br />
• Snap rasters to different grid This operation corresponds to resample a raster by snapping it<br />
to a grid defined by an arbitrary pixel corner and optionally a pixel size. New pixel values<br />
are computed using the NearestNeighbor, Bilinear, Cubic, CubicSpline or Lanczos resampling<br />
algorithm. Default is NearestNeighbor. <strong>The</strong> simple example below uses ST_SnapToGrid(raster,<br />
cornerx, cornery, algorithm) function to snap a raster to a slightly different grid defined by the<br />
pixel corner (0.0002, 0.0002):<br />
SELECT ST_SnapToGrid(rast,0.0002, 0.0002)<br />
FROM dummy_rast;<br />
5.1.3 Vector to <strong>Raster</strong> Conversion<br />
<strong>The</strong> example below creates a raster containing a black circle using ST_As<strong>Raster</strong>(geometry, width,<br />
height, pixeltype) function. Its dimensions are 150x150 pixels and its pixel type is 2-bit unsigned<br />
integer (2BUI):<br />
SELECT ST_As<strong>Raster</strong>(ST_Buffer(ST_Point(1,5),10),150, 150, ’2BUI’);<br />
where ST_Buffer is used to return a geometry that represents all points whose distance from the<br />
point (1,5) is less than or equal to 10 pixels.<br />
5.1.4 <strong>Raster</strong> to Vector Conversion<br />
Figure 5.1: <strong>Raster</strong> circle [17].<br />
<strong>The</strong> conversion using ST_DumpAsPolygons(raster, band) returns a set <strong>of</strong> geomval (<strong>for</strong>med by a<br />
geometry and a pixel band value) rows from a given raster band. Default band number is 1. Each<br />
geometry is the union <strong>of</strong> all pixels that have the same pixel value.<br />
SELECT (ST_DumpAsPolygons(rast)).*<br />
FROM dummy_rast<br />
WHERE rid = 1;<br />
64