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.

4.19 Intersection<br />

<strong>The</strong> fact that <strong>PostGIS</strong> <strong>Raster</strong> achieves efficient conversion between raster and vector, is the base<br />

to implement certain operations over data, whether it is in raster or vector <strong>for</strong>mat. <strong>The</strong>se operations<br />

are essential in <strong>PostGIS</strong> because they contribute to the accomplishment <strong>of</strong> its second goal described<br />

in Chapter 3. This goal includes <strong>of</strong>fering a single set <strong>of</strong> overlay SQL function operating seamlessly<br />

on vector and raster data. Furthermore, in comparison to ORACLE Geo<strong>Raster</strong> (also in Chapter 3),<br />

they play an important role that makes <strong>PostGIS</strong> <strong>Raster</strong> more per<strong>for</strong>ming than ORACLE GEO<strong>Raster</strong><br />

and more adapted to various groups <strong>of</strong> users (experienced and inexperienced ones). Such operations<br />

include ST_Intersection() that makes intersection between raster and vector data. Several possible<br />

scenarios are available <strong>for</strong> this operation:<br />

1. A vector and vector intersection with a vector layer as a result.<br />

2. A vector and raster intersection with a raster layer as a result.<br />

3. A vector and raster intersection with a vector layer as a result.<br />

4. A raster and raster intersection with a raster layer as a result.<br />

<strong>The</strong> result can be a raster or a set <strong>of</strong> geometry-pixel value pairs (as in the case <strong>of</strong> ST_DumpAsPolygons())<br />

representing the shared portion <strong>of</strong> two geometries, two rasters or between a vectorization <strong>of</strong> a raster<br />

and a geometry. <strong>The</strong>se cases will be examined one by one in the following examples.<br />

Example 1.1: A vector and vector intersection with a vector layer as a result is illustrated in Figure<br />

4.47.<br />

Figure 4.47: Vector and vector intersection with a resulting vector layer [22].<br />

This example examines the first case <strong>of</strong> intersection between a geometric circle a with a geometric<br />

vegetation cover (type 1 in blue and type 2 in green). <strong>The</strong> result is a half circle in vector <strong>for</strong>mat with<br />

two attributes: a circle name and a cover type.<br />

Example 1.2: A vector and raster intersection with a raster layer as a result.<br />

In general, the intersection begins to select which raster tiles have to be loaded in order to construct<br />

an intersected raster extent (using ST_intersects()) containing all intersected raster tiles. In the<br />

first view, this paradigm makes the operation more efficient in the sense that the number <strong>of</strong> intersected<br />

raster tiles is <strong>of</strong>ten a small number in compare to whole number <strong>of</strong> existing raster tiles (see Figure<br />

4.48). In second view, the intersection operation works only with these intersected tiles. <strong>The</strong> raster<br />

extent construction is just the first phase because true intersection will take pixel values (raster <strong>for</strong>mat)<br />

or geometries (vector <strong>for</strong>mat) into account (using ST_intersection()).<br />

If the output is a raster, then the operation will attach pixel values in the final result as one in<br />

Figure 4.49. So the vegetation cover type represented by a raster is well known. In addition, the<br />

vector attribute is also conserved and become an attribute <strong>of</strong> the resulting raster.<br />

Example 1.3: A vector and raster intersection with a vector layer as a result.<br />

If the final result is expressed in vector <strong>for</strong>m, the intersecting raster tiles are first vectorized (using<br />

ST_DumpAsPolygon()) into a set <strong>of</strong> geometry-pixel value and this set is then intersected with the<br />

geometry using the ST_Intersection(vector, vector) function. At this stage, one more time, as<br />

vectorization is a complex task (it is related to each pixel value) and time consume, the paradigm<br />

56

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

Saved successfully!

Ooh no, something went wrong!