计算几何对象相交的所有网格对象。
语法
geomgrid[] ST_AsGrid(geometry geom, integer precision, bool degenerated default false);
参数
参数名称 | 描述 |
geom | 需要计算的几何对象。 |
precision | 精度级别,取值:1~32,数值越大代表计算越精细。 |
degenerated | 是否采用退化网格。 退化网格与普通网格的对比如下: |
描述
几何对象的空间参考必须是CGC2000(SRID=4490),如果不是则会调用空间投影变换函数(ST_Transform)对几何对象的坐标进行转换,请确保能正确转换到CGC2000坐标系统。
本函数将返回几何对象相交的网格对象数组,对于点、线或面数据分别返回对应的网格编码,如下图所示:
示例
select st_astext(st_asgrid(
ST_geomfromtext('POINT(116.31522216796875 39.910277777777778)',4490), 15));
st_astext
--------------------
{G001310322230230}
select st_astext(st_asgrid(
ST_geomfromtext('LINESTRING(122.48077 51.72814,122.47416 51.73714)',4490), 18));
st_astext
--------------------------------------------------------------------------------
{G001331032213300011,G001331032213300013,G001331032213122320,G00133103221312232
2,G001331032213300100,G001331032213122303,G001331032213122321,G00133103221312231
2}
select st_astext(st_asgrid(
ST_geomfromtext('POLYGON((-0.08077 -0.02814, 0.0482 -0.03, 0.07426 0.03724, -0.08077 -0.02814))',4490),15));
st_astext
--------------------------------------------------------------------------------
{G000000000000000,G000000000000001,G000000000000003,G000000000000010,G000000000
000011,G000000000000012,G000000000000013,G000000000000031,G000000000000102,G0000
00000000120,G100000000000000,G200000000000000,G200000000000001,G200000000000002,
G200000000000003,G200000000000010,G200000000000011,G200000000000012,G20000000000
0013,G300000000000000,G300000000000001,G300000000000002,G300000000000003,G300000
000000010,G300000000000011,G300000000000012,G300000000000013,G300000000000102}
select st_astext(st_asgrid(
ST_geomfromtext('POLYGON((-0.08077 -0.02814, 0.0482 -0.03, 0.07426 0.03724, -0.08077 -0.02814))',4490),15,true));
st_astext
--------------------------------------------------------------------------------
{G000000000000000,G000000000000001,G000000000000003,G00000000000001,G0000000000
00031,G000000000000102,G000000000000120,G100000000000000,G20000000000000,G200000
00000001,G30000000000000,G30000000000001,G300000000000102}
文档内容是否对您有帮助?