ST_Raster.export

Definition

The ST_Raster.export function writes either all or part of an ST_Raster object to an image file. This function was designed to be used only as part of the select list of a SQL SELECT statement.

Syntax

Oracle

export (filename IN VARCHAR2) RETURN VARCHAR2

export (filename IN VARCHAR2, 
        parameter_list IN VARCHAR2) RETURN VARCHAR2

PostgreSQL

export (raster IN ST_RASTER, 
        filename IN TEXT) RETURN TEXT

export (raster IN ST_RASTER, 
        filename IN TEXT, 
        parameter_list IN TEXT) RETURN TEXT

SQL Server

export (filename IN NVARCHAR, 
        parameter_list IN NVARCHAR) RETURN NVARCHAR

Returns

VARCHAR

Parameters

Parameters

Descriptions

filename

The name of the exported raster file

The filename parameter is a VARCHAR, so it must be enclosed in single quotes. The extension of the file name determines the raster format that will be used to export the file. Currently, the supported raster format for export is GeoTIFF. Therefore, append the .tif extension.

raster

The ST_Raster value to be exported

parameter_list

A comma-delimited list of parameters enclosed in single quotes that may include the following parameters:

  • band <1st band number>[,<2nd band number>],…,[nth band number]>—A comma-delimited list of band sequence numbers of the bands to be exported

    The pixel data is exported in the order of the band sequence numbers. If the parameter is not specified, all the bands are exported in regular band sequential order.

  • level <pyramid level>—The pyramid level of the ST_Raster object to be exported; the default is the base level (0).
  • compression <lzw | g3 | g4 | zip>—The compression used to create the image file; the default is to create the image file without compression.
  • window (minx,miny,maxx,maxy)—The extent of the ST_Raster object to be exported to an image file specified in pixel coordinates
  • extent (minx,miny,maxx,maxy)—The extent of the ST_Raster object to be exported to an image file specified in geographic coordinates
  • overwrite—If the file exists, overwrite it. The default behavior is to return an error if the file already exists.

Examples

These examples show the following:

  1. How to export an ST_Raster object to a GeoTIFF file called border.tif
  2. How to export the second pyramid level of an ST_Raster object, a GeoTIFF file, and pyramid.tif, in descending band sequence order

In these examples, the files are exported to the location on the DBMS server where SQL is processed. You will likely include a specific path with your file name. Be sure that path is valid for the DBMS server.

Oracle

  1. SELECT image.export('border.tif', 'compression=zip') 
      FROM BORDER t
      WHERE t.image.raster_id = 10;
    
  2. SELECT image.export('pyramid.tif', 'level=2, band=(3,2,1)')
      FROM BORDER
      WHERE image.raster_id = 20;
    

PostgreSQL

  1. SELECT export(image,'border.tif', 'compression=zip') 
      FROM border
      WHERE raster_id(image) = 10;
    
  2. SELECT export(image, 'pyramid.tif', 'level=2, band=(3,2,1)')
      FROM border
      WHERE raster_id(image) = 20;
    

SQL Server

  1. SELECT image.export('border.tif', 'compression=zip')
     FROM border
     WHERE image.raster_id = 10;
  2.  SELECT image.export('pyramid.tif', 'level=2, band=(3,2,1)')
    FROM border
    WHERE image.raster_id = 20;

11/18/2013