Load raster data

更新时间:
复制 MD 格式

Use ST_ImportFrom to load a raster data file from a local path or an OSS bucket into a Ganos raster table.

Prerequisites

Before you begin, make sure that:

  • Your RDS instance is authorized to access the raster data file.

  • If the file is stored in OSS, the RDS instance and the OSS bucket are in the same region. For details, see OSS domain names.

How it works

ST_ImportFrom loads a raster data file from your computer or an OSS bucket into Ganos.

Both path formats are supported:

SourcePath formatExample
Local fileAbsolute file path/home/beijing.tif
OSS bucketoss://ak:as@bucket/path/fileoss://ak:as@bucket/data/beijing.tif

Syntax

INSERT INTO <raster_table_name>(<raster_column_name>)
VALUES (ST_IMPORTFROM('<chunk_table_name>', '<path_to_raster_file>'));
ParameterDescription
raster_table_nameName of the table that contains the raster column
raster_column_nameName of the column that stores the raster object
chunk_table_nameName of the chunk table
path_to_raster_filePath to the raster file — a local file path or an OSS URL

For the full list of storage and import options, see ST_ImportFrom.

Load raster data

Step 1: Enable the Ganos raster extension

Run the following statement once per database to enable the ganos_raster extension and its dependencies:

CREATE EXTENSION Ganos_Raster CASCADE;

Step 2: Load the raster file

Choose the path format based on where the file is stored.

Load from a local path

Use a local file path when the raster file is on your computer:

-- Load a local GeoTIFF file into the raster table
INSERT INTO raster_table(name, rast)
VALUES ('local_file', ST_ImportFrom('chunk_table', '/home/beijing.tif'));

Load from an OSS bucket

Use an OSS URL when the raster file is stored in Object Storage Service (OSS). Make sure the RDS instance and the OSS bucket are in the same region:

-- Load a raster file from an OSS bucket
-- Format: oss://ak:as@bucket/path/to/file.tif
--   ak     — AccessKey ID
--   as     — AccessKey Secret
--   bucket — OSS bucket name
INSERT INTO raster_table(name, rast)
VALUES ('oss_file', ST_ImportFrom('chunk_table', 'oss://ak:as@bucket/data/beijing.tif'));

What's next

  • To query and analyze the raster data you loaded, see Raster SQL Reference.

  • To learn about all ST_ImportFrom parameters, see ST_ImportFrom.