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.

DROP INDEX spain_images_idx;<br />

CREATE INDEX spain_images_idx<br />

ON spain_images(image.spatialExtent)<br />

INDEXTYPE IS mdsys.spatial_index;<br />

In contrast, <strong>PostGIS</strong> <strong>Raster</strong> loads raster data and creates spatial index using simply these two<br />

commands:<br />

python raster2pgsql.py -r *.tif -t spain_images -s 4326 -k 50x50 -I -o spain.sql<br />

psql -d postgis_db -f spain.sql<br />

<strong>The</strong> first command uses Python loader to import a set <strong>of</strong> raster images into raster table spain_images<br />

(option -t). Option -I is used to create indexes over these rasters. All necessary code is created and<br />

registered in a SQL file spain.sql (option -o). <strong>The</strong>n, the second command will execute spain.sql<br />

in <strong>PostGIS</strong> database.<br />

3.2.4 Overlapping <strong>Raster</strong> and Vector Layers<br />

Each spatial instance has a spatial reference identifier (SRID). However, the result <strong>of</strong> any spatial<br />

method from two spatial instances is valid only if those instances that have the same SRID. It is the<br />

same in the case <strong>of</strong> overlapping operation between vector and raster data.<br />

To reset SRID <strong>of</strong> a geometry object, Geo<strong>Raster</strong> uses sdo_cs.trans<strong>for</strong>m() function [14]:<br />

SELECT sdo_cs.trans<strong>for</strong>m(geom, srid_number) geom FROM geom_table ;<br />

In the same way in <strong>PostGIS</strong> <strong>Raster</strong>:<br />

SELECT ST_Trans<strong>for</strong>m(the_geom, srid_number)) FROM geom_table;<br />

3.2.5 Loading <strong>Raster</strong> Data<br />

Loading Using Oracle Geo<strong>Raster</strong><br />

To load raster image into Geo<strong>Raster</strong>, firstly users need to create tables to store the raster data.<br />

One table stores the metadata and another one stores the data [14]:<br />

CREATE TABLE spain_images (image_id NUMBER PRIMARY KEY,<br />

image_description VARCHAR2(50), image SDO_GEORASTER);<br />

CREATE TABLE spain_images_rdt OF SDO_RASTER<br />

(PRIMARY KEY (rasterID, pyramidLevel, bandBlockNumber, rowBlockNumber,<br />

columnBlockNumber))<br />

TABLESPACE users LOB(rasterBlock) STORE AS SECUREFILE lobseg (NOCACHE);<br />

<strong>The</strong>n, the image is loaded using PL/SQL code:<br />

DECLARE<br />

geor SDO_GEORASTER;<br />

BEGIN<br />

-- Initialize an empty Geo<strong>Raster</strong> object into which the external image<br />

-- is to be imported.<br />

INSERT INTO spain_images<br />

VALUES( 1, ’Spain_TIFF_1’, sdo_geor.init(’spain_images_rdt’) );<br />

-- Import the TIFF image.<br />

SELECT image INTO geor FROM spain_images<br />

WHERE image_id = 1 FOR UPDATE;<br />

24

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

Saved successfully!

Ooh no, something went wrong!