計算幾何對象相交的所有網(wǎng)格對象。
語法
geomgrid[] ST_AsGrid(geometry geom, integer precision, bool degenerated default false);
參數(shù)
參數(shù)名稱 | 描述 |
參數(shù)名稱 | 描述 |
geom | 需要計算的幾何對象。 |
precision | 精度級別,取值:1~32,數(shù)值越大代表計算越精細(xì)。 |
degenerated | 是否采用退化網(wǎng)格。 退化網(wǎng)格與普通網(wǎng)格的對比如下: |
描述
幾何對象的空間參考必須是CGC2000(SRID=4490),如果不是則會調(diào)用空間投影變換函數(shù)(ST_Transform)對幾何對象的坐標(biāo)進(jìn)行轉(zhuǎn)換,請確保能正確轉(zhuǎn)換到CGC2000坐標(biāo)系統(tǒng)。
本函數(shù)將返回幾何對象相交的網(wǎng)格對象數(shù)組,對于點、線或面數(shù)據(jù)分別返回對應(yīng)的網(wǎng)格編碼,如下圖所示:
示例
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}
- 本页导读 (1)
- 語法
- 參數(shù)
- 描述
- 示例
文档内容是否对您有帮助?