Showing posts with label insert. Show all posts
Showing posts with label insert. Show all posts

Wednesday, May 28, 2008

Oracle Georaster

Hi Friends,
Here are the simple steps to insert the Raster image into Oracle(Oracle Georaster).
  • Make object table

create table Landsat7 (id number,name varchar2(45),georaster sdo_georaster);

  • Make raster data table

CREATE TABLE Landsat7_RDT OF SDO_RASTER (PRIMARY KEY(RASTERID, PYRAMIDLEVEL, BANDBLOCKNUMBER,ROWBLOCKNUMBER, COLUMNBLOCKNUMBER))LOB(RASTERBLOCK) STORE AS (NOCACHE NOLOGGING);· execute CREATEDMLTRIGGER on table Landsat7o EXECUTE SDO_GEOR_UTL.CREATEDMLTRIGGER('Landsat7','GEORASTER');

  • Set permissions

call dbms_java.grant_permission('MDSYS','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tif', 'read' );o call dbms_java.grant_permission('GEOSPATIAL','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tif', 'read' );o call dbms_java.grant_permission('PUBLIC','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tif', 'read' );o call dbms_java.grant_permission('MDSYS','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tfw', 'read' );o call dbms_java.grant_permission('GEOSPATIAL','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tfw', 'read' );o call dbms_java.grant_permission('PUBLIC','SYS:java.io.FilePermission', 'C:\oracle\raster\georaster_table.tfw', 'read' );

  • Insert in the landsat7 Object Table.

INSERT INTO Landsat7 VALUES(1,'p174r037',SDO_GEOR.INIT('Landsat7_RDT'));·

  • Insert Geotiff with world file. (make Sure that images should be copied into the server. i.e C: means server C: Drive)

Declare

geo SDO_GEORASTER;

BEGINSELECT GEORASTER INTO geo FROM Landsat7 WHERE ID=1 FOR UPDATE;SDO_GEOR.IMPORTFROM(geo,'blocksize=(512,512)','TIFF','file','C:\oracle\raster\georaster_table.tif','WORLDFILE','file','C:\oracle\raster\georaster_table.tfw');UPDATE Landsat7 SET GEORASTER = geo WHERE ID=1;END;/

  • set SRID to georaster (WGS84 UTM zone 36)

DECLARE

geo sdo_georaster;

BEGIN

SELECT georaster INTO geo FROM Landsat7 WHERE id=1 FOR UPDATE;sdo_geor.setModelSRID(geo, 32636);UPDATE Landsat7 SET georaster = geo WHERE id=1;

END;

  • Set Extend
UPDATE Landsat7 cSET c.georaster.spatialExtent = sdo_geor.generateSpatialExtent(georaster)WHERE c.id = 1;COMMIT;
  • Compute Pyramide

DECLARE

geo sdo_georaster;

BEGIN

SELECT georaster INTO geo from landsat7 where id = 1 FOR UPDATE;sdo_geor.generatePyramid(geo, 'rLevel=5, resampling=NN');UPDATE landsat7 SET georaster = geo where id = 1;

COMMIT;

END;

  • Check Data and Metadata.


select count(*) from Landsat7;
select count(*) from Landsat7_RDT;
set long 10000;
select a.georaster.metadata from Landsat7 a;
SELECT t.id, sdo_geor.validategeoraster(t.georaster) isvalid from Landsat7 t order by id;

format the above code and use it... please let us know if you need any help.

Regards,
GIS Programmers.