7.102 SDO_GEOR.importFrom

Format

Note:

The SDO_GEOR.importFrom subprogram in the SDO_GEOR package is deprecated.
SDO_GEOR.importFrom(
     georaster      IN OUT SDO_GEORASTER, 
     storageParam   IN VARCHAR2, 
     r_sourceFormat IN VARCHAR2, 
     r_sourceType   IN VARCHAR2, 
     r_sourceName   IN VARCHAR2, 
     h_sourceFormat IN VARCHAR2 DEFAULT NULL, 
     h_sourceType   IN VARCHAR2 DEFAULT NULL, 
     h_sourceName   IN VARCHAR2 DEFAULT NULL);

or

SDO_GEOR.importFrom(
     georaster      IN OUT SDO_GEORASTER, 
     storageParam   IN VARCHAR2, 
     r_sourceFormat IN VARCHAR2, 
     r_sourceBLOB   IN BLOB, 
     h_sourceFormat IN VARCHAR2 DEFAULT NULL, 
     h_sourceCLOB   IN CLOB DEFAULT NULL);

Description

Imports an image file or BLOB object into a GeoRaster object stored in the database.

Parameters

georaster

GeoRaster object to hold the result of the operation.

storageParam

String containing storage parameters. The format and usage are as explained in Storage Parameters. Currently, the keywords supported for this operation are:

  • blocking: (See the explanation in Table 1-1 in Storage Parameters.)

  • blocksize: (See the explanation in Table 1-1 in Storage Parameters.)

  • compression: (See the explanation in Table 1-1 in Storage Parameters.) The default value is NONE, which causes the raw data to be loaded without any compression.

  • quality: (See the explanation in Table 1-1 in Storage Parameters.)

  • raster: TRUE (the default) causes the raster image data in a GeoTIFF format file to be loaded along with the georeferencing information; FALSE causes only the georeferencing information to be loaded from the GeoTIFF format file, without the raster image data, into an existing GeoRaster object.

  • spatialExtent: FALSE (the default) causes a spatial extent not to be generated; TRUE causes a spatial extent to be generated if the SRID is nonzero and matches the SRID of any existing spatial extent index.

r_sourceFormat

Raster source format. Must be one of the following: TIFF, GIF, BMP, or PNG. (JPEG is not supported for this procedure.)

r_sourceType

Type of source for the import operation. Must be FILE.

r_sourceName

Source file name (with full path specification) if r_sourceType is FILE. If you are using this procedure only to load the world file into an existing GeoRaster object, specify a null value for this parameter.

r_sourceBLOB

Raster source object of type BLOB.

h_sourceFormat

Geoheader source format. Must be WORLDFILE.

h_sourceType

Geoheader type of source for the import operation. Must be FILE.

h_sourceName

Geoheader source file name (with full path specification) if h_sourceType is FILE., and optionally an SRID value. To specify the SRID value, add it after the file name, separated by a comma. Example: '/mypath/mydir/worldfile.tfw,82934' (UNIX or Linux) or 'C:\mypath\mydir\worldfile.tfw,82934' (Windows)

h_sourceCLOB

Geoheader source as an object of type CLOB.

Usage Notes

Note:

This SDO_GEOR.importFrom procedure is not supported in Oracle Autonomous Database in both shared and dedicated deployments.

For information about using this procedure or the GeoRaster loader tool to load raster data, see Loading Raster Data.

If you receive an "insufficient memory" error when loading a very large image, see Reformatting the Source Raster Before Loading.

When loading an image into a GeoRaster database, you should always specify a block size, and it should generally be 512x512 or larger.

Specify values for the parameters with names that start with r_ and h_ only if the raster image and the geoheader are in separate files or objects.

This procedure can load an ESRI world file from a file or from a CLOB object.

This procedure does not support JPEG as a source file format.

This procedure does not support raster data that has a cell depth value of 2BIT or source multiband raster data with BIL and BSQ interleaving types.

The imported GeoRaster object has the BIP interleaving type.

Before this procedure is called, the calling user and the MDSYS user must have read permission on the files to be imported or the directory that contains the files. The following example (run as user SYSTEM) grants read permission on a file to users HERMAN and MDSYS:

call dbms_java.grant_permission('HERMAN','SYS:java.io.FilePermission',
  '/mydirectory/myimages/img1.tif', 'read' );
call dbms_java.grant_permission('MDSYS','SYS:java.io.FilePermission',
  '/mydirectory/myimages/img1.tif', 'read' );

Examples

The following example initializes an empty GeoRaster object into which an external image in TIFF format is to be imported, and then imports the image. The example grants the necessary permissions at the beginning and revokes them at the end.

connect / as sysdba

call dbms_java.grant_permission('HERMAN','SYS:java.io.FilePermission',
  '/mydirectory/myimages/img1.tif', 'read' );
call dbms_java.grant_permission('MDSYS','SYS:java.io.FilePermission',
  '/mydirectory/myimages/img1.tif', 'read' );

connect herman/<password>

DECLARE   
   geor SDO_GEORASTER;
BEGIN  
-- Initialize an empty GeoRaster object into which the external image
-- is to be imported. 
INSERT INTO georaster_table
   values( 1, 'TIFF', sdo_geor.init('rdt_1') );  

-- Import the TIFF image. 
SELECT georaster INTO geor FROM georaster_table 
   WHERE georid = 1 FOR UPDATE; 
sdo_geor.importFrom(geor, 'blocking=OPTIMALPADDING,blocksize=(512,512,3)', 'TIFF', 'file', 
   '/mydirectory/myimages/img1.tif');  
UPDATE georaster_table SET georaster = geor WHERE georid = 1;  
COMMIT;
END;/

connect / as sysdba

call dbms_java.revoke_permission('HERMAN','SYS:java.io.FilePermission',
  '/mydirectory/myimages/img1.tif', 'read' );
call dbms_java.revoke_permission('MDSYS','SYS:java.io.FilePermission',
  '/mydirectory/myimages/img1.tif', 'read' );

The following example imports an image from a BLOB and an ESRI world file from a CLOB. The image and the ESRI world file are stored in the BLOB and CLOB columns defined in the table blob_table.

CREATE TABLE blob_table (blob_col BLOB, blobid NUMBER unique, clob_col CLOB);

DECLARE
  geor1 SDO_GEORASTER;
  lobd1 BLOB;
  lobd2 CLOB; 
BEGIN

-- Get the image and world file from BLOB and CLOB, respectively.
SELECT clob_col into lobd2 from blob_table WHERE blobid = 2 ;
SELECT blob_col into lobd1 from blob_table WHERE blobid = 2 ;
 
-- Then, import this BLOB into a GeoRaster object.
SELECT georaster INTO geor1 from georaster_table WHERE georid = 14 for update;
sdo_geor.importFrom(geor1,'', 'TIFF', lobd1, 'WORLDFILE', lobd2);
sdo_geor.setModelSRID(geor1, 82394);
UPDATE georaster_table SET georaster = geor1 WHERE georid = 14;
COMMIT; 
END;
/