All Products
Search
Document Center

PolarDB:Raster model

Last Updated:Mar 28, 2026

GanosBase Raster is a spatial-temporal extension for PolarDB for PostgreSQL that stores and manages raster data — from satellite imagery and aerial photographs to scanned maps and digital pictures. It supports raster data from remote sensing, photogrammetry, and thematic mapping, and integrates a GeoServer plug-in to publish raster data as OGC (Open Geospatial Consortium)-compliant services such as Web Map Service (WMS) or Web Map Tile Service (WMTS).

GanosBase Raster is well-suited for spatial analysis workloads where you need to combine raster data with relational data in a single query. It is not optimized for high-throughput retrieval of raw image bytes — use a purpose-built raster-serving solution for that.

Key concepts

Raster data model

A raster is a matrix of cells organized into rows and columns. Each cell stores a numeric value — making a raster fundamentally a georeferenced numeric matrix, not just an image. This means you can run statistical and algebraic operations on raster data directly in the database, alongside your other relational data.

GanosBase Raster organizes raster data into the following elements:

ElementDescription
RasterA raster dataset, such as a remote sensing image or a TIFF file. Each raster is stored as a single database record.
TileThe basic storage unit of a raster object. Each tile is 256 x 256 pixels by default.
BandA single 2D layer in a raster dataset. Each band comprises multiple tiles, each with its own coordinate numbers.
CellA single pixel within a tile. Supported data types: byte, short, int, or double.
PyramidA series of reduced-resolution versions of a raster. Level 0 is the raw data.
MetadataPer-raster metadata including spatial extent, projection type, and pixel type.
image

In the database, each raster image is stored as a single raster object. That object is logically divided into bands, physically stored and managed by tiles, and described by metadata (spatial extent, data type, projection information, and coordinate numbers). If the raster uses a pyramid structure, each band has its own pyramid.

Storage model

GanosBase Raster keeps raster metadata in the database while storing raster attribute data on OSS (Object Storage Service). This separation keeps large raster datasets manageable at low cost. Each raster record can be up to 1 TB.

Spatial reference system

The spatial reference system (SRS) defines how a raster object maps to a location on Earth. GanosBase uses a Spatial Reference Identifier (SRID) to link each raster object to its SRS definition.

For more information, see Spatial reference.

raster_columns view

The raster_columns view lists all raster columns in the current database.

ColumnTypeDescription
r_table_catalogvarchar(256)The database that contains the table. Generally fixed to postgres.
r_table_schemavarchar(256)The schema that contains the raster table.
r_table_namevarchar(256)The name of the raster table.
r_raster_columnvarchar(256)The name of the raster column.

Query all raster columns in the current database:

SELECT * FROM raster_columns;

Indexes

A spatial index eliminates full sequential scans by organizing spatial data in a search tree for fast traversal.

GanosBase Raster supports two index types:

IndexBest forCharacteristics
B-tree indexQueries by raster file nameThe most commonly used index type; accelerates a wide range of query operations.
GIN index (Generalized Inverted Index)Full-text search; locating tuples containing specified keywordsFaster lookups on static data; moderately slower to update than GiST indexes.

Use cases

GanosBase Raster stores and analyzes raster data from a variety of fields, including meteorology, environmental monitoring, geological exploration, natural resource management, national defense, emergency response, telecommunications, media, transportation, urban planning, and homeland security.

Smart agriculture

Store and retrieve massive volumes of remote sensing satellite data. Use band calculations and spatial statistics across thematic and imagery data to support agricultural production analysis. Pair with DataV, a data visualization tool, to display results through maps and statistical graphs.

image

Meteorological and hydrological forecasting

Import and query data in standard formats including HDF, NetCDF, and GRIB. Apply spatial interpolation and contour/isosurface extraction to derive critical meteorological and hydrological information for disaster prevention.

Agricultural finance and insurance

Run rapid statistical analysis of crop types, coverage, and growth across time and space using band calculation and classification. Combine with risk control models to estimate crop yields and values from farmer self-declarations, farmland transfer records, climate data, and geographic locations. This approach helps determine reasonable credit limits and repayment cycles for farmers.

Features

  • Multi-format support: Reads and writes TIFF, IMG, HDF, NetCDF, and GRIB.

  • Raster queries: Query basic attributes, band statistics, and pixel value statistics; retrieve pixel matrices in multiple ways.

  • Raster operations: Projection conversion, cropping, band operations, mosaic, and color balancing.

  • Dynamic tiling: On-demand visualization through dynamic raster tiling.

  • Statistical and algebraic operators: Per-pixel and per-band computations, specialized color balancing algorithms, and accelerated rendering for overview maps on large-scale datasets.

  • Object-oriented storage: One raster per database record (up to 1 TB), with no direct tile-level operations — preserving metadata integrity and enabling tight correlation with time series data.

Quick start

This section walks through installing the GanosBase Raster extension, importing raster data from OSS, running queries, building a pyramid, and exporting results.

Prerequisites

Before you begin, ensure that you have:

  • A PolarDB for PostgreSQL cluster

  • An OSS bucket containing raster files

  • Your OSS access key ID and access key secret

Install the extension

Install ganos_raster without specifying a schema:

CREATE EXTENSION ganos_raster CASCADE;

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

Use ST_ImportFrom to load a raster file from OSS. Replace <ak>, <ak_secret>, and the bucket path with your actual values:

INSERT INTO raster_table
VALUES (
  1,
  ST_ImportFrom(
    'chunk_table',
    'OSS://<ak>:<ak_secret>@oss-cn-internal.aliyuncs.com/bucket/data/image.tif'
  )
);
PlaceholderDescriptionExample
<ak>Your access key IDLTAI5tXxx...
<ak_secret>Your access key secretxXxXxXx...
Access OSS through the correct OSS domain names. For path format details, see Object storage service paths.

Query raster attributes

Get the height and width of the imported raster:

SELECT ST_Height(rast), ST_Width(rast)
FROM raster_table
WHERE id = 1;

Expected output:

-----------
  1241
(1 rows)

Get statistics for band 0:

SELECT ST_Statistics(rast, 0)
FROM raster_table
WHERE id = 1;

Expected output:

{"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

Pyramids speed up rendering at lower resolutions by pre-computing reduced-resolution versions of the raster. Build the pyramid before running viewport-based queries:

UPDATE raster_table
SET rast = ST_BuildPyramid(rast)
WHERE id = 1;

Expected output: UPDATE 1

Find the optimal pyramid level for an 800 x 600 viewport over a bounding box:

SELECT ST_BestPyramidLevel(
  rast,
  '((128.0, 30.0),(128.5, 30.5))',  -- bounding box (world coordinates)
  800,                               -- viewport width in pixels
  600                                -- viewport height in pixels
)
FROM raster_table
WHERE id = 10;

Expected output: 3

Clip and export

Query the pixel matrix within a bounding box at band 0:

SELECT ST_Clip(rast, 0, '((128.980,30.0),(129.0,30.2))', 'World')
FROM raster_table
WHERE id = 1;

Get the pixel coordinate boundaries of a clipped area at pyramid level 2:

SELECT ST_ClipDimension(rast, 2, '((128.0, 30.0),(128.5, 30.5))')
FROM raster_table
WHERE id = 10;

Expected output: '((600, 720),(200, 300))'

Clip to a polygon geometry and export to Cloud Optimized GeoTIFF (COG) format:

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),
    0
  ),
  'COG',
  'OSS://<ak>:<ak_secret>@oss-cn.aliyuncs.com/mybucket/data/image_clip.tif'
);

Expected output: t (1 row)

Drop the extension

DROP EXTENSION ganos_raster CASCADE;

What's next