返回以几何对象表示的网格对象范围。
语法
geometry ST_AsGeometry(geomgrid grid);
geometry[] ST_AsGeometry(geomgrid[] grid);
geometry ST_AsGeometry(h3grid grid);
参数
参数名称 | 描述 |
grid | 需要输出的网格对象,数据类型为GeomGrid或者H3Grid。 |
示例
select st_astext(
st_asgeometry(st_gridfromtext('G0013103220310313')));
st_astext
--------------------------------------------------------------------------------
POLYGON((116.458888888889 39.3088888888889,116.458888888889 39.3166666666667,11
6.466666666667 39.3166666666667,116.466666666667 39.3088888888889,116.4588888888
89 39.3088888888889))
select st_astext(unnest(st_asgeometry(st_as3dgrid(
'srid=4490;POLYGON Z ((116 39 1000,116.12 39 2000,116.12 39.09 2000,116 39.09 2000,116 39 1000),(116.024 39.018 5000,116.024 39.045 4000,116.06 39.045 3000,116.06 39.018 3000,116.024 39.018 5000))'::geometry,8))));
st_astext
--------------------------------------------------------------------------------
GEOMETRYCOLLECTION Z (POLYGON Z ((114 38 0,114 40 0,116 40 0,116 38 0,114 38 0)
),POLYGON Z ((114 38 224581.873222534,116 38 224581.873222534,116 40 224581.8732
22534,114 40 224581.873222534,114 38 224581.873222534)),POLYGON Z ((114 38 0,114
38 224581.873222534,114 40 224581.873222534,114 40 0,114 38 0)),POLYGON Z ((116
38 0,116 40 0,116 40 224581.873222534,116 38 224581.873222534,116 38 0)),POLYGO
N Z ((114 38 0,116 38 0,116 38 224581.873222534,114 38 224581.873222534,114 38 0
)),POLYGON Z ((114 40 0,114 40 224581.873222534,116 40 224581.873222534,116 40 0
,114 40 0)))
GEOMETRYCOLLECTION Z (POLYGON Z ((116 38 0,116 40 0,118 40 0,118 38 0,116 38 0)
),POLYGON Z ((116 38 224581.873222534,118 38 224581.873222534,118 40 224581.8732
22534,116 40 224581.873222534,116 38 224581.873222534)),POLYGON Z ((116 38 0,116
38 224581.873222534,116 40 224581.873222534,116 40 0,116 38 0)),POLYGON Z ((118
38 0,118 40 0,118 40 224581.873222534,118 38 224581.873222534,118 38 0)),POLYGO
N Z ((116 38 0,118 38 0,118 38 224581.873222534,116 38 224581.873222534,116 38 0
)),POLYGON Z ((116 40 0,116 40 224581.873222534,118 40 224581.873222534,118 40 0
,116 40 0)))
-- H3编码
select st_astext(st_asgeometry(st_h3fromlatlng(20.5,128.2,8)));
st_astext
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------
POLYGON((128.191668807576 20.5021234642116,128.190846860853 20.4973493612535,128.194924841007 20.4945095494225,128.19982492147 20.4964439288771,128.200646976708 20.5012181556083,128.196568842975 20.504
0578791202,128.191668807576 20.5021234642116))