Tuesday, December 21, 2010

Run GDAL on Oracle Enterprise Linux

How to recompile GDAL reference document
Document reference URL http://http://www.oracle.com/technetwork/database/enterprise-edition/gdal-howto-compile-linux-130782.txt?ssSourceSiteId=otncn
For GDAL
========

Make sure your $ORACLE_HOME environment variable is set.  If it is, SDO_GEORASTER will automatically be part of the GDAL build.


http://trac.osgeo.org/gdal/
Click on BuildHints
Click on DownloadSource
click on http://download.osgeo.org/gdal 
click on daily
stable is stable code, trunk is code under development (you choose which one you want to compile).
                       trunk may contain fixes to SDO_GEORASTER extension that are not in stable.
.gz files are source code for UNIX/Linux, .zip files are source code for Windows
Unzip the source
cd to top level directory of source tree 


mkdir full_path_to_GDAL_INSTALL_directory/GDAL_INSTALL

Call configure. Backslash ('\') is the continuation character for a UNIX command line
./configure --help

./configure \
--prefix=full_path_to_GDAL_INSTALL_directory/GDAL_INSTALL \
--with-ecw=full_path_to_GDAL_INSTALL_directory/ECW_INSTALL

setenv LD_LIBRARY_PATH full_path_to_GDAL_INSTALL_directory/ECW_INSTALL/lib
make
make install

Add full_path_to_GDAL_INSTALL_directory/GDAL_INSTALL/bin to your path environent variable.
To test install, georaster should appear as one of the gdalinfo formats.
For example, run the gdalinfo command as follows:

gdalinfo --formats

  --  ECW (rw): ERMapper Compressed Wavelets
  --  GeoRaster (rw+): Oracle Spatial GeoRaster


Load I0022461-WGS84.GRE.ers into raster_table FIRST time (create a raster_table and column)
gdal_translate -of georaster I0022461-WGS84.BLU.ers georaster:scott/tiger,,raster_table,raster \
>  -co "DESCRIPTION=(image_name varchar2(45), raster MDSYS.SDO_GEORASTER)" \
> -co "INSERT=VALUES('I0022461-WGS84.BLU',SDO_GEOR.INIT())" \
> -co "INTERLEAVE=BAND" -co "SRID=8307"

Load two more raster files into same table
gdal_translate -of georaster I0022461-WGS84.GRE.ers georaster:scott/tiger,,raster_table,raster \
-co "INSERT=VALUES('I0022461-WGS84.GRE',SDO_GEOR.INIT('RDT_1$', 3))" \
-co "INTERLEAVE=BAND" -co "SRID=8307"

gdal_translate -of georaster I0022461-WGS84.RED.ers georaster:scott/tiger,,raster_table,raster \
-co "INSERT=VALUES('I0022461-WGS84.RED',SDO_GEOR.INIT('RDT_1$', 4))" \
-co "INTERLEAVE=BAND"  -co "SRID=8307"

After load files, update Geometry Metadata
insert into USER_SDO_GEOM_METADATA values('RASTER_TABLE', 'RASTER.SPATIALEXTENT',
SDO_DIM_ARRAY(
    SDO_DIM_ELEMENT('X', 119.214515610089, 119.794140610089, 0.005),
    SDO_DIM_ELEMENT('Y', 23.1398648460264, 23.8549398460264, 0.005)
), 8307);
  commit;

Create pyramids for all the rasters in the table
DECLARE
  geor_v  sdo_georaster;
  status  varchar2(20);
BEGIN
  FOR r in (SELECT image_name FROM raster_table ORDER BY georid) LOOP
    SELECT raster INTO geor_v
    FROM raster_table
    WHERE image_name = r.image_name
    FOR UPDATE;

    sdo_geor.generatePyramid(geor_v, 'resampling=NN');

    UPDATE image_table
    SET raster = geor_v
    WHERE image_name = r.image_name;

    COMMIT;
  END LOOP;
END;
/


Create Spatial Index
create index raster_table_raster_sdo_extent
on raster_table(raster.spatialextent)
indextype
is mdsys.spatial_index;

No comments: