GanosBase Raster is a spatiotemporal extension for PolarDB for PostgreSQL (Compatible with Oracle) that stores, manages, and analyzes raster data directly in your database. It supports data from remote sensing, photogrammetry, and thematic mapping sources, and includes a GeoServer plug-in to publish raster data as OGC-compliant Web Map Service (WMS) or Web Map Tile Service (WMTS) services.
Key concepts
A raster is a matrix of cells organized in rows and columns, where each cell holds a value such as a temperature reading or elevation. Think of it as a grid pinned to a coordinate system — similar to a spreadsheet mapped onto the earth's surface. Unlike vector data (points, lines, polygons), raster data represents continuous phenomena such as aerial photographs, satellite imagery, digital elevation models (DEMs), and scanned maps.
GanosBase Raster stores each raster dataset as a single database record with the following elements:
| Element | Description |
|---|---|
| Raster | A complete raster dataset — for example, a remote sensing image or a TIFF file. Each record can hold up to 1 TB. |
| Tile | The basic storage unit. Each tile is 256 x 256 pixels by default and can be resized as needed. |
| Band | A single 2D layer within a raster dataset. Each band comprises multiple tiles, each with its own coordinate numbers. |
| Cell | A single pixel within a tile. Supported data types: byte, short, int, and double. |
| Pyramid | A set of reduced-resolution versions of the raster used to speed up display. Level 0 is the raw data; each higher level is a lower-resolution copy. |
| Metadata | Attributes associated with the raster, including spatial extent, projection type, and pixel type. |

In the database, each raster object is logically divided into multiple bands. Bands hold the raw image data loaded during import. Tiles store and manage the actual data, and each tile can span one or more bands. If a raster is organized in a pyramid structure, each band has its own pyramid.
Spatial reference system
GanosBase uses a Spatial Reference Identifier (SRID) to associate a raster object with its spatial reference system (SRS) — the coordinate framework that maps the data to a location on the earth's surface. For details, see Spatial reference.
The raster_columns view
The raster_columns view lists all raster columns in the current database:
| Column | Type | Description |
|---|---|---|
r_table_catalog | varchar(256) | The database containing the table. Fixed to postgres. |
r_table_schema | varchar(256) | The schema of the raster table. |
r_table_name | varchar(256) | The name of the raster table. |
r_raster_column | varchar(256) | The name of the raster column. |
To list all raster columns in the current database:
SELECT * FROM raster_columns;Indexes
A spatial index eliminates full table scans by organizing data in a search tree, which speeds up queries on large raster datasets. GanosBase Raster supports two index types:
| Index | Best for | Notes |
|---|---|---|
| B-tree index | Queries by raster file name | The standard PostgreSQL index; broad query support |
| Generalized Inverted Index (GIN) | Full-text search; finding tuples that contain specific keywords | Faster lookups on static data; slower to update than GiST indexes |
Use cases
GanosBase Raster is well-suited for the following scenarios:
Smart agriculture: Store and retrieve large volumes of remote sensing satellite data. Use spatial thematic data, satellite imagery, band calculations, and spatial statistics to support agricultural production analysis. Integrate with DataV to display results as maps and charts.

Meteorological and hydrological forecasting: Import and query standard meteorological and hydrological formats — HDF, NetCDF, and GRIB. Apply spatial interpolation and contour or isosurface extraction to generate critical forecasting data for disaster prevention.
Agricultural finance and insurance: Use band calculation and crop classification to analyze crop types, coverage, and growth conditions across time and space. Combine results with risk control models to estimate crop yields and set credit terms for farmers.
Supported formats
GanosBase Raster supports the following input and output formats: TIFF, IMG, HDF, NetCDF, and GRIB. Export is also supported in COG (Cloud Optimized GeoTIFF) format.
Capabilities
GanosBase Raster provides the following capabilities:
Query a raster object's basic attributes, band statistics, and pixel value statistics
Retrieve pixel matrices in multiple ways
Perform operations including projection conversion, cropping, band calculation, mosaic, and color balancing
Dynamic raster tiling for on-demand visualization
A hybrid storage architecture: raster metadata stays in the database while raster attribute data is stored on Object Storage Service (OSS), reducing storage costs for large-scale imagery analysis
Statistical and algebraic operations, image color balancing algorithms, and accelerated rendering for overview maps on large datasets
Quick start
This section walks through a complete workflow: install the extension, create a table, import raster data, query raster properties and band statistics, build a pyramid, clip a region, and export the result.
Prerequisites
Before you begin, ensure that you have:
A running PolarDB for PostgreSQL (Compatible with Oracle) cluster
An OSS bucket containing a raster file to import
An Alibaba Cloud AccessKey ID and AccessKey Secret with OSS read access (for importing raster data) and write access (for exporting results)
Install the extension
You can install the extension using either of the following forms. Installing into the public schema is recommended to avoid potential permission issues.
-- Basic form
CREATE EXTENSION ganos_raster CASCADE;
-- Recommended: install into the public schema to avoid permission issues
CREATE EXTENSION ganos_raster WITH SCHEMA public CASCADE;Create a raster table
CREATE TABLE raster_table(id integer, rast raster);Import raster data from OSS
INSERT INTO raster_table VALUES(
1,
ST_ImportFrom(
'chunk_table',
-- Replace <ak> and <ak_secret> with your AccessKey ID and AccessKey Secret.
-- Access OSS using an OSS domain name. See: https://www.alibabacloud.com/help/en/oss/user-guide/oss-domain-names
-- For OSS path format details, see: https://www.alibabacloud.com/help/en/polardb/polardb-for-oracle/object-storage-service-path-1
'OSS://<ak>:<ak_secret>@oss-cn-internal.aliyuncs.com/bucket/data/image.tif'
)
);Query raster properties
GanosBase Raster functions operate at two levels:
Raster level: Return properties of the entire raster object (for example,
ST_Height,ST_Width).Band level: Operate on a single band within the raster (for example,
ST_Statistics). The band index argument specifies which band to use.
Get dimensions (width and height in pixels):
SELECT ST_Height(rast), ST_Width(rast)
FROM raster_table
WHERE id = 1;Expected output:
st_height | st_width
-----------+----------
1241 | ...
(1 row)Get statistics for a specific band:
The second argument (0) is the band index.
SELECT ST_Statistics(rast, 0) -- band index 0
FROM raster_table
WHERE id = 1;Expected output (JSON):
{
"approximate": false,
"min": 8969.0,
"max": 12351.0,
"mean": 9407.330013839151,
"std": 193.4268180351078,
"count": 70091,
"sum": 659369168.0,
"mode": 9366.0,
"median": 9392.0
}Build a pyramid
A pyramid pre-computes reduced-resolution versions of the raster, enabling fast rendering at different zoom levels. Level 0 is the original data.
UPDATE raster_table
SET rast = ST_BuildPyramid(rast)
WHERE id = 1;
-- Output: UPDATE 1Find the optimal pyramid level for a given viewport:
The following query returns the pyramid level that best matches a viewport defined by its world coordinate bounding box, width (800 pixels), and height (600 pixels). A higher level means a lower-resolution version of the data.
SELECT ST_BestPyramidLevel(
rast,
'((128.0, 30.0),(128.5, 30.5))', -- world coordinate bounding box
800, -- viewport width in pixels
600 -- viewport height in pixels
)
FROM raster_table
WHERE id = 10;Expected output:
st_bestpyramidlevel
--------------------
3
(1 row)A result of 3 means pyramid level 3 fits the specified viewport most efficiently.
Clip a region
Query the pixel matrix within a bounding box (band 0):
SELECT ST_Clip(rast, 0, '((128.980, 30.0),(129.0, 30.2))', 'World')
FROM raster_table
WHERE id = 1;Calculate the pixel coordinate boundaries of a clipped area (pyramid level 2):
SELECT ST_ClipDimension(rast, 2, '((128.0, 30.0),(128.5, 30.5))')
FROM raster_table
WHERE id = 10;Expected output:
st_clipdimension
------------------------
'((600, 720),(200, 300))'
(1 row)Clip and export
Clip a portion of the raster using a polygon geometry and export the result to COG format in OSS:
SELECT ST_ExportTo(
ST_ClipToRast(
rast,
ST_GeomFromText(
'POLYGON((128.0 30.0, 129.0 30.0, 129.0 31.0, 128.0 31.0, 128.0 30.0))',
4326 -- SRID: WGS 84
),
0 -- band index
),
'COG', -- output format: Cloud Optimized GeoTIFF
-- Replace <ak> and <ak_secret> with your AccessKey ID and AccessKey Secret.
'OSS://<ak>:<ak_secret>@oss-cn.aliyuncs.com/mybucket/data/image_clip.tif'
);Expected output:
st_exportto
-------------
t
(1 row)A result of t (true) confirms the export succeeded.
Drop the extension
If you no longer need GanosBase Raster, remove the extension and all associated objects:
DROP EXTENSION ganos_raster CASCADE;Next steps
For a complete list of SQL functions, see Raster SQL reference.