Load raster data

更新时间:
复制 MD 格式

Use ST_ImportFrom to load raster files (such as GeoTIFF) into GanosBase from a local file system or an Alibaba Cloud Object Storage Service (OSS) bucket.

Prerequisites

Before you begin, ensure that you have:

  • A PolarDB for PostgreSQL instance with the Ganos_Raster extension installed (see step 1 below)

  • Access to the raster data file from the instance

  • If the raster file is stored in OSS: the instance and the OSS bucket must be in the same region. For details, see OSS domain names

How it works

ST_ImportFrom reads a raster file from the specified path and loads it into a raster column in GanosBase.

Load raster data into GanosBase

Step 1: Install the Ganos_Raster extension

Run the following command once per database:

CREATE EXTENSION Ganos_Raster CASCADE;

Step 2: Insert a raster file

Use ST_ImportFrom to load a raster file into a raster table.

Syntax

INSERT INTO <raster_table_name>(<raster_column_name>)
VALUES (ST_ImportFrom('<chunk_table_name>', '<path_to_raster_file>'));
ParameterDescription
<raster_table_name>The table that stores raster metadata
<raster_column_name>The raster-type column in that table
<chunk_table_name>The name of the chunk table where GanosBase stores tiled raster data
<path_to_raster_file>The file path: a local path for files on the same host, or an OSS URI for files stored in OSS

Load from the local file system

INSERT INTO raster_table(name, rast)
VALUES ('local_file', ST_ImportFrom('chunk_table', '/home/beijing.tif'));

Load from an OSS bucket

INSERT INTO raster_table(name, rast)
VALUES ('oss_file', ST_ImportFrom('chunk_table', 'oss://<AccessKeyId>:<AccessKeySecret>@<bucket>/data/beijing.tif'));

Replace the placeholders in the OSS URI:

PlaceholderDescription
<AccessKeyId>Your Alibaba Cloud AccessKey ID
<AccessKeySecret>Your Alibaba Cloud AccessKey Secret
<bucket>The OSS bucket name
Note: For a full list of ST_ImportFrom parameters, see ST_ImportFrom. For other raster functions available in GanosBase, see Raster SQL Reference.

What's next

After loading raster data, use GanosBase raster functions to query, analyze, and process the data. See Raster SQL Reference for the complete function list.