全部產品
Search
文件中心

ApsaraDB RDS:ST_AsH3Grid

更新時間:Feb 28, 2024

將二維幾何對象轉換為H3網格表達。

文法

h3grid[] ST_AsH3Grid(geometry geom, integer precision, bool degenerated default false);

參數

參數名稱

描述

geom

需要計算網格對象的幾何對象。

precision

精度層級,取值範圍:0~15。

degenerated

是否採用退化網格。

描述

  • 退化網格原理與H3相同。

  • SRID可以為任何投影,函數會自動完成投影轉換。

樣本

-- POINT
select ST_AsH3Grid(st_geomfromtext('POINT(2932234 234234)',28992),4);

st_ash3grid
--------------------------
{010101FFFFFFFF09D54208}

--LINESTRING
select st_ash3grid('SRID=4326;LINESTRING(122.48077 51.72814,122.47416 51.73714)'::geometry, 10);

st_ash3grid
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
-----------------------------------
{010100FFFF59698658A108,010100FF7F58698658A108,010100FFFF5A698658A108,010100FF7F51698658A108,010100FF7F50698658A108,010100FF7F52698658A108,010100FF7FCD698658A108,010100FF7FCF698658A108,010100FF7FCE698658A108,010100FFFFC0698658A108,010100FF7FC7698658A108,010100FFFFD5698658A108}
(1 row)

-- MULTIPOLYGON
SELECT ST_AsH3Grid('SRID=4326;MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(2 2,2 5,5 5,5 2,2 2))) '::geometry, 2);

st_ash3grid
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
-----
 {010100FFFFFFFF7F882508,010100FFFFFFFF7F2C2808,010100FFFFFFFF7F2D2808,010100FFFFFFFF7F8B2508,010100FFFFFFFF7F2F2808,010100FFFFFFFF7F8D2508,010100FFFFFFFF7F892508,010100FFFFFFFF7F8F2508,010100FFFFFFFF7F542708,010100FFFFFFFF7F572708,010100FFFFFFFFFF882508,010100FFFFFFFFFF892508,010100FFFFFFFFFF2D2808,010100FFFFFFFFFF2E2808,010100FFFFFFFFFF8A2508,010100FFFFFFFFFF5708}
(1 row)