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.
One approach to make this intersection operation without <strong>PostGIS</strong> <strong>Raster</strong> is to convert those<br />
raster images to shapefiles (a popular geospatial vector data <strong>for</strong>mat), import them in <strong>PostGIS</strong> and do<br />
a traditional intersection query between geometries only. <strong>The</strong> problem is that converting only one <strong>of</strong><br />
those Shuttle Radar Topography Mission (SRTM) files is very difficult. <strong>The</strong> vector version <strong>of</strong> only one<br />
<strong>of</strong> those files exceeds the limit <strong>of</strong> 2 GB imposed on shapefiles. Since it is mostly impossible to convert<br />
those rasters to vectors, the <strong>PostGIS</strong> <strong>Raster</strong> approach is to load them into <strong>PostGIS</strong> and will vectorize<br />
only ones that are needed to do the requested operation. This approach benefits greatly from the<br />
indexing <strong>of</strong> raster data in the database.<br />
4.17 Retrieving<br />
As each storing type is specified <strong>for</strong> a class <strong>of</strong> application, it results in a strong difference in the way<br />
they retrieve raster data.<br />
4.17.1 In-database <strong>Raster</strong> Retrieving<br />
<strong>The</strong>re exist two modes when retrieving in-database raster data from <strong>PostGIS</strong> database:<br />
1. ONE RASTER PER ROW<br />
2. ONE RASTER PER TABLE<br />
<strong>PostGIS</strong> uses the GDAL driver <strong>for</strong> exporting rasters via a connection string. <strong>The</strong> syntax <strong>of</strong> this<br />
connection string is as follows:<br />
PG":host=’’ port:’’ dbname=’’ user=’’ password=’’<br />
[schema=’’] [table=’’] [where=’’]<br />
[mode=’’]"<br />
Certain fields can be omitted like password in some case. <strong>The</strong> table option specifies name <strong>of</strong> a<br />
raster table to connect. <strong>The</strong> where option is used to filter results from the raster table. <strong>The</strong> mode<br />
option determines which connection mode is evoked:<br />
• Mode = 1 or ONE RASTER PER ROW mode (the default mode): in this mode, a raster table is<br />
considered as a set <strong>of</strong> different raster images. <strong>The</strong>n where parameter is used to select which<br />
raster images will be exported.<br />
• Mode = 2 or ONE RASTER PER TABLE mode: in this case, a raster table is considered as a unique<br />
raster image composed by a set <strong>of</strong> raster tiles (one raster tile per row). This mode is intended<br />
<strong>for</strong> reading tiled raster.<br />
When the connection is established, the GDAL driver uses gdal_translate command to create<br />
an image file from the connected raster table:<br />
gdal_translate -outsize 50% 50% "PG:host=’localhost’ dbname=’’<br />
user=’’ password=’’ table=’table_name’ mode=’2’"<br />
table_name.tif<br />
<strong>The</strong> additional option -outsize will create an image file like the original image but at a different<br />
size (a half size in the above example).<br />
4.17.2 Out-database <strong>Raster</strong> Retrieving<br />
<strong>PostGIS</strong> <strong>Raster</strong> enables user to simply register basic metadata <strong>of</strong> images stored in the filesystem<br />
without having to actually load their data values into the database. This is out-database storage as<br />
opposed to the more natural in-database storage. In this way, web or desktop applications:<br />
• do not have to retrieve images from the database but instead can access them directly from the<br />
file system (such as JPEG files).<br />
• can use almost <strong>PostGIS</strong> <strong>Raster</strong> operators and functions on those rasters using GDAL driver<br />
(out-database raster support is under development).<br />
54