簡(jiǎn)介

柵格數(shù)據(jù)由按行和列(或格網(wǎng))組織的像元(或像素)矩陣組成,其中的每個(gè)像元都包含一個(gè)信息值(例如溫度)。

柵格數(shù)據(jù)可以是數(shù)字航空像片、衛(wèi)星影像、數(shù)字圖片或掃描的地圖。

Ganos時(shí)空引擎通過在ADB PG中實(shí)現(xiàn)柵格數(shù)據(jù)模型,可以借助于數(shù)據(jù)庫(kù)的技術(shù)和方法高效地對(duì)柵格數(shù)據(jù)進(jìn)行存儲(chǔ)和分析操作。

快速入門

  • 創(chuàng)建擴(kuò)展
    Create extension ganos_spatialref;
    Create extension ganos_geometry;
    Create Extension Ganos_Raster;
  • 創(chuàng)建柵格表
    -- 指定raster 列作為表的 distributed column
    Create Table raster_table(id integer, raster_obj raster) 
    DISTRIBUTED BY (raster_obj);
  • 從OSS中導(dǎo)入柵格數(shù)據(jù)
    Insert into raster_table 
    Values(1, ST_ImportFrom('chunk_table','OSS://<id>:<key>@oss-cn.aliyuncs.com/mybucket/data/my_image.tif')),
    (2, ST_CreateRast('OSS://<id>:<key>@oss-cn.aliyuncs.com/mybucket/data/my_image.tif'));
  • 查詢柵格對(duì)象信息
    Select ST_Height(raster_obj),ST_Width(raster_obj) From raster_table Where id = 1;
     st_height 
    -----------
          1241
    (1 rows)
  • 創(chuàng)建金字塔
    DO $$
    declare
        rast raster;
    begin
        select raster_obj into rast from raster_table where id = 1;
        rast = st_buildpyramid(rast);
        update raster_table set raster_obj = rast where id = 1;
    end;    
    $$ LANGUAGE 'plpgsql';
    
    DO $$
    declare
        rast raster;
    begin
        select raster_obj into rast from raster_table where id = 2;
        rast = st_buildpyramid(rast, -1, 'Near', 'chunk_table');
        update raster_table set raster_obj = rast where id = 2;
    end;    
    $$ LANGUAGE 'plpgsql';
  • 根據(jù)視口的世界坐標(biāo)范圍,長(zhǎng)和寬來(lái)計(jì)算最佳的金字塔層級(jí)
    Select ST_BestPyramidLevel(rast, '((128.0, 30.0),(128.5, 30.5))', 800, 600) from raster_table where id = 1;
    
    ---------------------
    3
  • 獲取柵格指定范圍像素矩陣
    DO $$
    declare
        rast raster;
    begin
        select raster_obj into rast from raster_table where id = 1;
        rast = st_buildpyramid(rast);
        Select ST_Clip(rast, 0, '((128.980,30.0),(129.0,30.2))', 'World');
    end;    
    $$ LANGUAGE 'plpgsql';
  • 計(jì)算裁剪的像素坐標(biāo)范圍
    Select ST_ClipDimension(raster_obj, 2, '((128.0, 30.0),(128.5, 30.5))') 
    from raster_table where id = 1;
    
    ------------------------------------
    '((600, 720),(200, 300))'
  • 刪除擴(kuò)展
    DROP Extension Ganos_Raster;
    DROP extension ganos_geometry;
    DROP extension ganos_spatialref;

SQL參考

詳細(xì)SQL參考請(qǐng)參見Raster SQL參考。