10.2 SDO_GEOR_GDAL.translate
Format
SDO_GEOR_GDAL.translate( inDirectory IN SDO_VARCHAR2, InFileName IN OUT SDO_VARCHAR2, outGeoRaster IN OUT SDO_GEORASTER, options IN VARCHAR2 DEFAULT NULL, createOptions IN VARCHAR2 DEFAULT NULL, metadataOptions IN VARCHAR2 DEFAULT NULL, openOptions IN VARCHAR2 DEFAULT NULL);
or
SDO_GEOR_GDAL.translate( inGeoRaster IN SDO_GEORASTER, outDirectory IN VARCHAR2, outFileName IN VARCHAR2, options IN VARCHAR2 DEFAULT NULL, createOptions IN VARCHAR2 DEFAULT NULL, metadataOptions IN VARCHAR2 DEFAULT NULL, openOptions IN VARCHAR2 DEFAULT NULL);
or
SDO_GEOR_GDAL.translate( inGeoRaster IN SDO_GEORASTER, outGeoRaster IN OUT SDO_GEORASTER, options IN VARCHAR2 DEFAULT NULL, createOptions IN VARCHAR2 DEFAULT NULL, metadataOptions IN VARCHAR2 DEFAULT NULL, openOptions IN VARCHAR2 DEFAULT NULL);
or
SDO_GEOR_GDAL.translate( inGeoRaster IN MDSYS.SDO_GEORASTER, outTableName IN VARCHAR2, outRasterid IN NUMBER, options IN VARCHAR2 DEFAULT '', createOptions IN VARCHAR2 DEFAULT '', metadataOptions IN VARCHAR2 DEFAULT '', openOptions IN VARCHAR2 DEFAULT '');
or
SDO_GEOR_GDAL.translate( inTableName IN VARCHAR2, inRasterid IN NUMBER, outGeoRaster IN OUT MDSYS.SDO_GEORASTER, options IN VARCHAR2 DEFAULT '', createOptions IN VARCHAR2 DEFAULT '', metadataOptions IN VARCHAR2 DEFAULT '', openOptions IN VARCHAR2 DEFAULT '');
Description
Converts raster data between different formats, potentially performing some operations like subsettings, resampling, and rescaling pixels in the process.
Parameters
- inDirectory
-
The name of a directory object pointing at the system directory containing the input file.
- inFileName
-
A base file name (file name without path) of any GDAL compatible raster data source specification.
- inGeoRaster
-
Input GeoRaster object.
- outGeoRaster
-
GeoRaster object to hold the result of the operation. Must be a valid initialized GeoRaster object. Cannot be the same GeoRaster object as
inGeoRaster
. - outDirectory
-
The name of a directory object pointing at the system directory to contain the output file.
- outFileName
-
Name of the output file.
- inTableName
-
The table or view name in which the input raster is stored in a BLOB column. See the Usage Notes for more information.
- inRasterid
-
The ID to identify the row in the table where the input raster is stored in a BLOB column. See the Usage Notes for more information.
- outTableName
-
The table or view name in which the output raster is to be stored in a BLOB column. See the Usage Notes for more information.
- outRasterid
-
The ID to identify the row in the table where the output raster is to be stored in a BLOB column. See the Usage Notes for more information.
- options
-
When specified, identifies options for the GDAL translate operation. See the Usage Notes for a table of names and explanations of possible
options
parameter values.Example:
options => 'srcwin=100,100,2500,2500'
- createOptions
-
When specified, identifies options specific to the output driver. Format 'name=value', with options separated by space. Example:
"COMPRESS=JPEG-F GENPYRAMID=NN"
. - metadataOptions
-
When specified, assigns metadata values specific to the output driver. Format 'name=value', with options separated by space. Example:
"TIFFTAG_POINTAREA=AREA"
. - openOptions
-
When specified, identifies options specific to the input driver format. See the GDAL supported format list for details.
Usage Notes
This function performs the same action as the GDAL translate
command.
The source and the target raster data can be stored in a file system, in a BLOB in a table, or in a GeoRaster object. Also, note the following:
- The raster data that is stored in a file system is identified by the combination of a
database directory object name and a file name, such as
(inDirectory, inFileName)
or(outDirectory, outFileName)
. - The raster data that is stored in a BLOB is identified by a table or view
name and an ID, such as
(inTableName, inRasterid)
or(outTableName, outRasterid)
. Note that the table or view that stores the raster in BLOB must have at least the following two columns:(rasterblock BLOB, rasterid NUMBER)
, whererasterblock
column stores the raster andrasterid
is used to identify the raster.
The options parameter possible keywords are listed in the following table.
Table 10-2 options Parameter Possible Values for translate Operations
Keyword | Explanation |
---|---|
|
Array of band numbers. Integer list; 1 is the first band. Example: If not specified, the band list from the input file will be used. |
|
Show error when |
|
Show error when |
|
Apply non linear scaling with a power function. Must be positive. Used with the scale option. Example: |
|
The name of GDAL driver that support dataset creating. String type. Example: |
|
Ground Control Points. May be provided multiple times to provide a set of GCPs. In the format |
|
Array of band numbers. Integer list, where 1 is the first band. Example: If not specified, the band list from the input file will be used. |
|
List of Nodata value (or |
|
Assigned the output bounds of the output image in the format |
|
The spatial reference system (SRS) for |
|
Output pixel data type. Supported values are: If this option is not specified, the input data type will be used. Check if the output format support the data type in use. |
|
Set the size of the output image defined by rows and columns or by the relative percentage of the original image size. Example:
If not specified, the original size of the input image will be used. |
|
Source window sub region from input image defined in coordinates as in |
|
The spatial reference system (SRS) for |
|
Indicate whether to copy the source image raster attribute table to the output image . Default is The operation depend on the capacity of the output format to support raster attribute table. |
|
Resampling mode { |
|
Indicate whether to translate a dataset with 1 band with a color table as a dataset with 3 (RGB) or 4 (RGBA) bands. Expands a dataset with a color table that only contains gray levels to a gray indexed dataset. { |
|
List of values to rescale the pixel values from the input image to the output image. The values cam be defined as |
|
Source window subregion from input image defined in pixels coordinates as in If not specified, the entire input image will be used. |
|
Calculate and store statistics on output image. Boolean type; default is |
|
Raise an error if are data type mismatches and lost data when translating to the output format. Boolean type; default is |
|
Output horizontal and vertical output image resolution. Example: : |
For convenience, the arguments of the options
parameter can also be entered in the same format as the GDAL gdal_translate
command line tool. Example: “-srcwin 10 10 512 512 –outsize 1024 1024“
Examples
The following example loads a geotiff file from the file system to an initialized GeoRaster object.
CREATE OR REPLACE DIRECTORY mydata_dir AS '/folder_name/data/'; BEGIN DELETE FROM imagery WHERE id = 1; INSERT INTO imagery VALUES(1, sdo_geor.init('imagery_rdt',1)) RETURNING raster INTO gr; sdo_geor_gdal.translate(inDirectory => 'mydata_dir', inFileName => 'sample.tif', outGeoRaster => gr); UPDATE imagery SET raster = gr WHERE id = 1; COMMIT; END;
The following example exports a GeoRaster object to a geotiff file.
CREATE OR REPLACE DIRECTORY dump_dir AS '/folder_name/dump/'; DECLARE gr sdo_georaster; BEGIN SELECT raster INTO gr FROM imagery WHERE id = 1; sdo_geor_gdal.translate(inGeoRaster => gr, outDirectory => 'dump_dir', outFileName => 'copy_imagery_id_1.tif'); END;
The following example copies a GeoRaster object into another cropping part of the image while changing the resolution and the scale of values.
DECLARE gr1 sdo_georaster; gr2 sdo_georaster; BEGIN DELETE FROM imagery WHERE id = 2; SELECT raster INTO gr1 WHERE id = 2; INSERT INTO imagery VALUES(2, sdo_geor.init('imagery',2)) RETURNING raster INTO gr2; sdo_geor_gdal.translate( inGeoraster => gr1, options => 'srcwin=100,100,2500,2500' || 'scale=0,255' || 'resxy=400,400', outGeoRaster => gr); UPDATE imagery SET raster = gr2 WHERE id = 2; COMMIT; END;
The following example exports a GeoRaster object into a file in Erdas .img
format.
CREATE OR REPLACE DIRECTORY myoutput_dir AS '/folder_name/data/'; DECLARE gr sdo_georaster; BEGIN SELECT raster INTO gr where id = 3; sdo_geor_gdal.translate( inGeoraster => gr, outDirectory => myoutput_dir,, outFilename => 'exported.img', options => 'format=hfa'); END;
The following example exports a GeoRaster object into a BLOB in the table
raster_table
, where the raster_table
is defined as
(rasterid number, rasterblock BLOB)
:
DECLARE gr sdo_georaster; BEGIN INSERT INTO raster_table VALUES (100, empty_blob()); SELECT raster INTO gr FROM imagery WHERE id = 1; sdo_geor_gdal.translate(inGeoRaster => gr, outTableName => 'raster_table', outRasterid => 100); COMMIT; END;
The following example imports the raster data stored in a BLOB in the table
raster_table
into a GeoRaster object. The raster_table
is defined as (rasterid number, rasterblock BLOB)
:
DECLARE gr sdo_georaster; BEGIN INSERT INTO imagery VALUES (2, sdo_geor.init(‘imagery_rdt’, 2)) RETURNING raster INTO gr; sdo_geor_gdal.translate( inTableName => 'raster_table', inRasterid => 100, outGeoRaster => gr); UPDATE imagery SET raster = gr WHERE id= 2; COMMIT; END;
Parent topic: SDO_GEOR_GDAL Package Reference