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
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
4.18 Conversion<br />
In <strong>PostGIS</strong>, when using analysis functions, it is no matter whether the layers are raster or vector<br />
type as <strong>PostGIS</strong> <strong>Raster</strong> provides a set <strong>of</strong> functions to support conversion between raster and vector<br />
data.<br />
4.18.1 <strong>Raster</strong> to vector<br />
With ST_DumpAsPolygons() function, raster data is converted to vector <strong>for</strong>m, along with a set <strong>of</strong><br />
geometric objects.<br />
Example:<br />
SELECT ST_DumpAsPolygons(rast)).geom, ST_DumpAsPolygons(rast)).val<br />
FROM raster_table ;<br />
<strong>The</strong> result <strong>of</strong> this function is a set <strong>of</strong> geomval <strong>for</strong>med by a geometry and a pixel value, where each<br />
geometric object is the union <strong>of</strong> all pixels <strong>of</strong> the same band that have the same pixel value. So the<br />
ST_DumpAsPolygons() function is useful <strong>for</strong> polygonizing rasters in which a single raster will be split<br />
and trans<strong>for</strong>med into multiple polygons. For example, as the circle in Figure 4.45 is composed by two<br />
half-circles that have different values, when applying the ST_DumpAsPolygons() function, it results in<br />
two geometric half-circles by definition.<br />
4.18.2 Vector to raster<br />
Figure 4.45: Conversion from raster to vector [22].<br />
Inversely, a raster object can be build from a geometric object using ST_As<strong>Raster</strong>() function. <strong>The</strong><br />
vector to raster conversion can be per<strong>for</strong>med without loss <strong>of</strong> in<strong>for</strong>mation as <strong>PostGIS</strong> <strong>Raster</strong> introduces<br />
the concept <strong>of</strong> raster object. This concept postulates that geographic entities can be stored as raster<br />
tiles at variable sizes instead <strong>of</strong> polygons. In the following demonstration, the request will output a<br />
raster containing image <strong>of</strong> a black geometric circle taking up 150 x 150 pixels as the one in Figure<br />
4.46.<br />
Select ST_As<strong>Raster</strong>(ST_Buffer(ST_Point(1,5),10),150, 150, ’2BUI’);<br />
Figure 4.46: Conversion from vector to raster [22].<br />
55