Raster data consists of a matrix of cells (or pixels) organized into rows and columns (or a grid) where each cell contains a value that represents information, such as temperature.


Raster data can be digital aerial photographs, imagery from satellites, digital pictures, or even scanned maps.

By implementing the raster model in ApsaraDB RDS for PostgreSQL, Ganos Raster can efficiently store and analyze raster data with the help of database technologies and methods.

Quick start

  • Create an extension.

    Create Extension Ganos_Raster cascade;
  • Create a raster table.

    Create Table raster_table(id integer, raster_obj raster);
  • Import raster data from Object Storage Service (OSS).

    Insert into raster_table Values(1, ST_ImportFrom('chunk_table','OSS://ABCDEFG:1234567890@oss-cn.aliyuncs.com/mybucket/data/4.tif'))
  • Query raster object information.

    Select ST_Height(raster_obj),ST_Width(raster_obj) From raster_table Where id = 1;
  • Create a pyramid.

    Update raster_table Set raster_obj = ST_BuildPyramid(raster_obj) Where id = 1;
  • Compute the best pyramid level based on the world space, width, and height of a viewport.

    Select ST_BestPyramidLevel(raster_obj, '((128.0, 30.0),(128.5, 30.5))', 800, 600) from raster_table where id = 10;
  • Obtain a pixel matrix from the specified space of a raster object.

    Select ST_Clip(raster_obj, 0, '((128.980,30.0),(129.0,30.2))', 'World') From raster_table Where id = 1;
  • Compute the raster space of a clipped area.

    Select ST_ClipDimension(raster_obj, 2, '((128.0, 30.0),(128.5, 30.5))') from rater_table where id = 10;
    '((600, 720),(200, 300))'
  • Delete the extension.

    Drop Extension Ganos_raster cascade;

SQL reference

For more information, see Raster SQL reference.