ST_AsH3Grid

将二维几何对象转换为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)