您好,登錄后才能下訂單哦!
Data Lake Analytics的Geospatial分析函數(shù)怎么理解,相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
為滿(mǎn)足部分客戶(hù)在云上做Geometry數(shù)據(jù)的分析需求,阿里云Data Lake Analytics(以下簡(jiǎn)稱(chēng):DLA)支持多種格式的地理空間數(shù)據(jù)處理函數(shù),符合Open Geospatial Consortium’s (OGC) OpenGIS規(guī)范,支持的常用數(shù)據(jù)格式包括:
WKT
WKB
GeoJson
ESRI Geometry Object Json
ESRI Shape
DLA采用4326坐標(biāo)系標(biāo)準(zhǔn),EPSG 4326使用經(jīng)緯度坐標(biāo),屬于地理坐標(biāo)系。GPS采用的就是這個(gè)坐標(biāo)系。
詳細(xì)描述:
https://en.wikipedia.org/wiki/Well-known_text
http://www.opengeospatial.org/standards/wkt-crs
支持類(lèi)似如下的WKT相關(guān)字符串。
POINT (0 0)
LINESTRING (0 0, 1 1, 1 2)
POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1))
MULTIPOINT (0 0, 1 2)
MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))
MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))
GEOMETRYCOLLECTION (POINT (2 3), LINESTRING (2 3, 3 4))
詳細(xì)描述:https://en.wikipedia.org/wiki/Well-known_text#Well-known_binary
上述WKT數(shù)據(jù)和WKB的對(duì)應(yīng)示例:
WKT | WKB |
---|---|
POINT (0 0) | 010100000000000000000000000000000000000000 |
LINESTRING (0 0, 1 1, 1 2) | 01020000000300000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000040 |
POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)) | 01030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F000000000000F03F0000000000000040000000000000004000000000000000400000000000000040000000000000F03F000000000000F03F000000000000F03F |
MULTIPOINT (0 0, 1 2) | 0104000000020000000101000000000000000000000000000000000000000101000000000000000000F03F0000000000000040 |
MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4)) | 01050000000200000001020000000300000000000000000000000000000000000000000000000000F03F000000000000F03F000000000000F03F0000000000000040010200000003000000000000000000004000000000000008400000000000000840000000000000004000000000000014400000000000001040 |
MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1))) | 01060000000200000001030000000200000005000000000000000000000000000000000000000000000000001040000000000000000000000000000010400000000000001040000000000000000000000000000010400000000000000000000000000000000005000000000000000000F03F000000000000F03F000000000000F03F0000000000000040000000000000004000000000000000400000000000000040000000000000F03F000000000000F03F000000000000F03F01030000000100000005000000000000000000F0BF000000000000F0BF00000000000000C0000000000000F0BF00000000000000C000000000000000C0000000000000F0BF00000000000000C0000000000000F0BF000000000000F0BF |
GEOMETRYCOLLECTION (POINT (2 3), LINESTRING (2 3, 3 4)) | 0107000000020000000101000000000000000000004000000000000008400102000000020000000000000000000040000000000000084000000000000008400000000000001040 |
GeoJson的詳細(xì)描述:http://geojson.org/
規(guī)范說(shuō)明:http://resources.esri.com/help/9.3/arcgisserver/apis/REST/geometry.html
規(guī)范說(shuō)明:http://www.esri.com/LIBRARY/WHITEPAPERS/PDFS/SHAPEFILE.PDF
Name | Description |
---|---|
ST_asText | 將Geometry數(shù)據(jù)轉(zhuǎn)成WKT格式的字符串?dāng)?shù)據(jù)。 |
ST_LineFromText | 輸入WKT格式的Line字符串?dāng)?shù)據(jù),生成Line的Geometry數(shù)據(jù)。 |
ST_Point | 從坐標(biāo)系的坐標(biāo)值(X, Y),生成對(duì)應(yīng)的Point的Geometry數(shù)據(jù)。 |
ST_Polygon | 輸入WKT格式的Polygon字符串?dāng)?shù)據(jù),生成Polygon的Geometry數(shù)據(jù)。 |
ST_Area | 返回面或多面的面積。對(duì)于點(diǎn)、線(xiàn),返回0.0。對(duì)于GeometryCollection,返回所有單個(gè)面積的和。 |
ST_GeometryFromText | 輸入WKT格式的字符串?dāng)?shù)據(jù),生成Geometry數(shù)據(jù)。 |
ST_Buffer | 獲取幾何對(duì)象和距離,然后返回表示圍繞源對(duì)象的緩沖區(qū)的幾何對(duì)象。 |
ST_Centroid | 獲取幾何對(duì)象的中心點(diǎn)。 |
ST_CoordDim | 返回幾何對(duì)象的坐標(biāo)值維度。 |
ST_Dimension | 用于返回幾何對(duì)象的維度。在這種情況下,維度是指長(zhǎng)度和寬度。例如,點(diǎn)既沒(méi)有長(zhǎng)度也沒(méi)有寬度,所以其維度為 0;而線(xiàn)只有長(zhǎng)度卻沒(méi)有寬度,因此其維度為 1。 |
ST_IsClosed | 判斷Line或者M(jìn)ultiLine是否閉合。 |
ST_IsEmpty | 判斷幾何對(duì)象是否為空。 |
ST_Length | 計(jì)算Line或者M(jìn)ultiLine的長(zhǎng)度。 |
ST_XMax | 返回幾何對(duì)象在坐標(biāo)系中的最大X坐標(biāo)值。 |
ST_XMin | 返回幾何對(duì)象在坐標(biāo)系中的最小X坐標(biāo)值。 |
ST_YMax | 返回幾何對(duì)象在坐標(biāo)系中的最大Y坐標(biāo)值。 |
ST_YMin | 返回幾何對(duì)象在坐標(biāo)系中的最小Y坐標(biāo)值。 |
ST_NumInteriorRing | 以Polygon作為輸入?yún)?shù),并返回其內(nèi)部環(huán)數(shù)。 |
ST_NumPoints | 用于返回幾何對(duì)象中的點(diǎn)(折點(diǎn))數(shù)。 |
ST_IsRing | 以L(fǎng)ine作為輸入?yún)?shù),判斷是否是環(huán)(如Line是閉合的)。 |
ST_StartPoint | 用于返回Line的第一個(gè)點(diǎn)。 |
ST_EndPoint | 用于返回Line的最后一個(gè)點(diǎn)。 |
ST_X | 返回Point的X坐標(biāo)。 |
ST_Y | 返回Point的Y坐標(biāo)。 |
ST_Boundary | 輸入一個(gè)幾何對(duì)象,然后以幾何對(duì)象形式返回其組合邊界。 |
ST_Envelope | 以多邊形的形式返回幾何對(duì)象的最小邊界框。 |
ST_Difference | 輸入兩個(gè)幾何對(duì)象,然后返回表示兩個(gè)源對(duì)象之差的幾何對(duì)象。 |
ST_Distance | 用于返回兩個(gè)幾何對(duì)象之間的距離。這一距離是兩個(gè)幾何對(duì)象的最近折點(diǎn)之間的距離。 |
ST_ExteriorRing | 以L(fǎng)ine形式返回面的外部環(huán)。 |
ST_Intersection | 以?xún)蓚€(gè)幾何對(duì)象作為輸入?yún)?shù),然后以二維幾何對(duì)象的形式返回交集。 |
ST_SymDifference | 返回表示兩個(gè)幾何對(duì)象間的點(diǎn)集對(duì)稱(chēng)差異的幾何值對(duì)象。 |
ST_Contains | 輸入兩個(gè)幾何對(duì)象,判斷第一個(gè)對(duì)象是否完全包含第二個(gè)對(duì)象。 |
ST_Crosses | 以?xún)蓚€(gè)幾何對(duì)象作為輸入,如果這兩個(gè)對(duì)象的交集生成的幾何對(duì)象的維度小于兩個(gè)源對(duì)象中的最大維度,則返回 1。交集對(duì)象所包含的點(diǎn)必須在兩個(gè)源幾何的內(nèi)部,并且不等于其中任何一個(gè)源對(duì)象。否則,返回 0。 |
ST_Disjoint | 輸入兩個(gè)幾何對(duì)象,判斷兩個(gè)幾何對(duì)象的交集是否為空集。 |
ST_Equals | 判斷兩個(gè)幾何對(duì)象是否完全相同。 |
ST_Intersects | 判斷兩個(gè)幾何對(duì)象的交集是否不生成空集。 |
ST_Overlaps | 判斷兩個(gè)幾何對(duì)象的交集生成的幾何對(duì)象是否維度相同但不等于任一源對(duì)象。 |
ST_Relate | 比較兩個(gè)幾何對(duì)象,判斷是否滿(mǎn)足“DE-9IM”模式(https://en.wikipedia.org/wiki/DE-9IM)矩陣字符串指定的條件。 |
ST_Touches | 判斷兩個(gè)幾何對(duì)象的公共點(diǎn)是否都不與兩個(gè)幾何對(duì)象的內(nèi)部相交。 |
ST_Within | 判斷第一個(gè)幾何對(duì)象是否完全位于第二個(gè)幾何對(duì)象的范圍內(nèi)。 |
ST_asBinary | 輸入一個(gè)幾何對(duì)象,然后返回其可識(shí)別的二進(jìn)制WKB數(shù)據(jù)。 |
ST_GeometryFromWKBHexString | 輸入WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。 |
ST_pointFromWKBHexString | 輸入Point的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的Point幾何對(duì)象。 |
ST_lineFromWKBHexString | 輸入Line的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的Line幾何對(duì)象。 |
ST_polyFromWKBHexString | 輸入Polygon的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的Polygon幾何對(duì)象。 |
ST_MPointFromWKBHexString | 輸入MultiPoint的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的MultiPoint幾何對(duì)象。 |
ST_MLineFromWKBHexString | 輸入MultiLine的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的MultiLine幾何對(duì)象。 |
ST_MPolyFromWKBHexString | 輸入MultiPolygon的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的MultiPolygon幾何對(duì)象。 |
ST_GeometryFromWKB | 輸入WKB數(shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。 |
ST_pointFromWKB | 輸入Point的WKB數(shù)據(jù),返回對(duì)應(yīng)的Point幾何對(duì)象。 |
ST_lineFromWKB | 輸入Line的WKB數(shù)據(jù),返回對(duì)應(yīng)的Line幾何對(duì)象。 |
ST_polyFromWKB | 輸入Polygon的WKB數(shù)據(jù),返回對(duì)應(yīng)的Polygon幾何對(duì)象。 |
ST_MPointFromWKB | 輸入MultiPoint的WKB數(shù)據(jù),返回對(duì)應(yīng)的MultiPoint幾何對(duì)象。 |
ST_MLineFromWKB | 輸入MultiLine的WKB數(shù)據(jù),返回對(duì)應(yīng)的MultiLine幾何對(duì)象。 |
ST_MPolyFromWKB | 輸入MultiPolygon的WKB數(shù)據(jù),返回對(duì)應(yīng)的MultiPolygon幾何對(duì)象。 |
ST_GeometryFromGeoJson | 輸入GeoJson的字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。 |
ST_GeometryFromJson | 輸入ESRI Geometry Object Json的字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。 |
ST_asGeoJson | 把幾何對(duì)象轉(zhuǎn)成GeoJson格式輸出。 |
ST_asJson | 把幾何對(duì)象轉(zhuǎn)成ESRI Geometry Object Json格式輸出。 |
ST_GeometryFromEsriShape | 輸入ESRI Shape的二進(jìn)制數(shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。 |
UDF_SYS_GEO_IN_CYCLE | 僅適用于北半球:做基于地理位置的經(jīng)緯度畫(huà)圈 |
UDF_SYS_GEO_IN_RECTANGLE | 僅適用于北半球:用于做基于地理位置的經(jīng)緯度畫(huà)矩形 |
UDF_SYS_GEO_DISTANCE | 僅適用于北半球:用作一個(gè)經(jīng)緯度列和一個(gè)固定的坐標(biāo)點(diǎn)的距離計(jì)算 |
ST_asText
ST_asText(GEOMETRY) -> VARCHAR
將Geometry數(shù)據(jù)轉(zhuǎn)成WKT格式的字符串?dāng)?shù)據(jù)。
示例:
select ST_asText(ST_LineFromText('LINESTRING (0 0, 1 1, 1 2)')); +----------------------------+ | _col0 | +----------------------------+ | LINESTRING (0 0, 1 1, 1 2) | +----------------------------+
ST_LineFromText
ST_LineFromText(VARCHAR) -> GEOMETRY
輸入WKT格式的Line字符串?dāng)?shù)據(jù),生成Line的Geometry數(shù)據(jù)。
示例:
select ST_asText(ST_LineFromText('LINESTRING (0 0, 1 1, 1 2)')); +----------------------------+ | _col0 | +----------------------------+ | LINESTRING (0 0, 1 1, 1 2) | +----------------------------+
ST_Point
ST_Point(DOUBLE, DOUBLE) -> GEOMETRY
從坐標(biāo)系的坐標(biāo)值(X, Y),生成對(duì)應(yīng)的Point的Geometry數(shù)據(jù)。
示例:
select ST_asText(ST_Point(30.2741500000,120.1551500000)); +----------------------------+ | _col0 | +----------------------------+ | POINT (30.27415 120.15515) | +----------------------------+
ST_Polygon
ST_Polygon(VARCHAR) -> GEOMETRY
輸入WKT格式的Polygon字符串?dāng)?shù)據(jù),生成Polygon的Geometry數(shù)據(jù)。
示例:
select ST_asText(ST_Polygon('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))')); +----------------------------------------------------------------+ | _col0 | +----------------------------------------------------------------+ | POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)) | +----------------------------------------------------------------+
ST_Area
ST_Area(Geometry) -> DOUBLE
返回面或多面的面積。對(duì)于點(diǎn)、線(xiàn),返回0.0。對(duì)于GeometryCollection,返回所有單個(gè)面積的和。
示例:
select ST_Area(ST_Polygon('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))')); +-------+ | _col0 | +-------+ | 15.0 | +-------+ select ST_Area(ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 16.0 | +-------+
ST_GeometryFromText
ST_GeometryFromText(VARCHAR) -> GEOMETRY
輸入WKT格式的字符串?dāng)?shù)據(jù),生成Geometry數(shù)據(jù)。
ST_Buffer
ST_Buffer(GEOMETRY, DOUBLE) -> GEOMETRY
獲取幾何對(duì)象和距離,然后返回表示圍繞源對(duì)象的緩沖區(qū)的幾何對(duì)象。
ST_Centroid
ST_Centroid(GEOMETRY) -> GEOMETRY
獲取幾何對(duì)象的中心點(diǎn)。
示例:
select ST_asText(ST_Centroid(ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'))); +-----------------------+ | _col0 | +-----------------------+ | POINT (1.8125 1.8125) | +-----------------------+ select ST_asText(ST_Centroid(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2)'))); +---------------+ | _col0 | +---------------+ | POINT (0.5 1) | +---------------+ select ST_asText(ST_Centroid(ST_GeometryFromText('POINT (0.5 1)'))); +---------------+ | _col0 | +---------------+ | POINT (0.5 1) | +---------------+ select ST_asText(ST_Centroid(ST_GeometryFromText('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))'))); +---------------------------------------------+ | _col0 | +---------------------------------------------+ | POINT (2.033333333333333 2.033333333333333) | +---------------------------------------------+
ST_CoordDim
ST_CoordDim(GEOMETRY) -> BIGINT
返回幾何對(duì)象的坐標(biāo)值維度。
示例:
select ST_CoordDim(ST_GeometryFromText('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))')); +-------+ | _col0 | +-------+ | 2 | +-------+ select ST_CoordDim(ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 2 | +-------+ select st_coorddim(st_geometryfromtext('point Z (60.567222 -140.404 5959)')); +-------+ | _col0 | +-------+ | 3 | +-------+ select st_coorddim(st_geometryfromtext('point M (60.567222 -140.404 5250)')); +-------+ | _col0 | +-------+ | 3 | +-------+ select st_coorddim(st_geometryfromtext('point ZM (60.567222 -140.404 5959 5250)')); +-------+ | _col0 | +-------+ | 4 | +-------+
ST_Dimension
ST_Dimension(GEOMETRY) -> BIGINT
用于返回幾何對(duì)象的維度。在這種情況下,維度是指長(zhǎng)度和寬度。例如,點(diǎn)既沒(méi)有長(zhǎng)度也沒(méi)有寬度,所以其維度為 0;而線(xiàn)只有長(zhǎng)度卻沒(méi)有寬度,因此其維度為 1。
示例:
select ST_Dimension(ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 2 | +-------+
ST_IsClosed
ST_IsClosed(GEOMETRY) -> BOOLEAN
判斷Line或者M(jìn)ultiLine是否閉合。
示例:
select ST_IsClosed(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2)')); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_IsClosed(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2, 0 0)')); +-------+ | _col0 | +-------+ | 1 | +-------+ select ST_IsClosed(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-------+ | _col0 | +-------+ | 0 | +-------+
ST_IsEmpty
ST_IsEmpty(GEOMETRY) -> BOOLEAN
判斷幾何對(duì)象是否為空。
示例:
select ST_IsEmpty(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2, 0 0)')); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_IsEmpty(null); +-------+ | _col0 | +-------+ | NULL | +-------+ SELECT ST_IsEmpty(ST_GeometryFromText('GEOMETRYCOLLECTION EMPTY')); +-------+ | _col0 | +-------+ | 1 | +-------+ SELECT ST_IsEmpty(ST_GeometryFromText('POLYGON EMPTY')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_Length
ST_Length(GEOMETRY) -> DOUBLE
計(jì)算Line或者M(jìn)ultiLine的長(zhǎng)度。
示例:
SELECT ST_Length(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2, 0 0)')); +-------------------+ | _col0 | +-------------------+ | 4.650281539872885 | +-------------------+ SELECT ST_Length(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-------------------+ | _col0 | +-------------------+ | 6.656854249492381 | +-------------------+
ST_XMax
ST_XMax(GEOMETRY) -> DOUBLE
返回幾何對(duì)象在坐標(biāo)系中的最大X坐標(biāo)值。
示例:
SELECT ST_XMax(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-------+ | _col0 | +-------+ | 5.0 | +-------+ SELECT ST_XMax(ST_GeometryFromText('POINT (0.5 1)')); +-------+ | _col0 | +-------+ | 0.5 | +-------+
ST_XMin
ST_XMin(GEOMETRY) -> DOUBLE
返回幾何對(duì)象在坐標(biāo)系中的最小X坐標(biāo)值。
示例:
SELECT ST_XMin(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-------+ | _col0 | +-------+ | 0.0 | +-------+ SELECT ST_XMin(ST_GeometryFromText('POINT (0.5 1)')); +-------+ | _col0 | +-------+ | 0.5 | +-------+
ST_YMax
ST_YMax(GEOMETRY) -> DOUBLE
返回幾何對(duì)象在坐標(biāo)系中的最大Y坐標(biāo)值。
示例:
SELECT ST_YMax(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-------+ | _col0 | +-------+ | 4.0 | +-------+ SELECT ST_YMax(ST_GeometryFromText('POINT (0.5 1)')); +-------+ | _col0 | +-------+ | 1.0 | +-------+
ST_YMin
ST_YMin(GEOMETRY) -> DOUBLE
返回幾何對(duì)象在坐標(biāo)系中的最小Y坐標(biāo)值。
示例:
SELECT ST_YMin(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-------+ | _col0 | +-------+ | 0.0 | +-------+ SELECT ST_YMin(ST_GeometryFromText('POINT (0.5 1)')); +-------+ | _col0 | +-------+ | 1.0 | +-------+
ST_NumInteriorRing
ST_NumInteriorRing(GEOMETRY) -> BIGINT
以Polygon作為輸入?yún)?shù),并返回其內(nèi)部環(huán)數(shù)。
示例:
SELECT ST_NumInteriorRing(ST_GeometryFromText('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_NumPoints
ST_NumPoints(GEOMETRY) -> BIGINT
用于返回幾何對(duì)象中的點(diǎn)(折點(diǎn))數(shù)。
示例:
SELECT ST_NumPoints(ST_GeometryFromText('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))')); +-------+ | _col0 | +-------+ | 8 | +-------+ SELECT ST_NumPoints(ST_GeometryFromText('POLYGON EMPTY')); +-------+ | _col0 | +-------+ | 0 | +-------+ SELECT ST_NumPoints(ST_GeometryFromText('POINT (0.5 1)')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_IsRing
ST_IsRing(GEOMETRY) -> BOOLEAN
以L(fǎng)ine作為輸入?yún)?shù),判斷是否是環(huán)(如Line是閉合的)。
示例:
select ST_IsRing(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2)')); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_IsRing(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2, 0 0)')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_StartPoint
ST_StartPoint(GEOMETRY) -> GEOMETRY
用于返回Line的第一個(gè)點(diǎn)。
示例:
select ST_asText(ST_StartPoint(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2, 0 0)'))); +-------------+ | _col0 | +-------------+ | POINT (0 0) | +-------------+
ST_EndPoint
ST_EndPoint(GEOMETRY) -> GEOMETRY
用于返回Line的最后一個(gè)點(diǎn)。
示例:
select ST_asText(ST_EndPoint(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2)'))); +-------------+ | _col0 | +-------------+ | POINT (1 2) | +-------------+
ST_X
ST_X(GEOMETRY) -> DOUBLE
返回Point的X坐標(biāo)。
示例:
select ST_X(ST_GeometryFromText('POINT (0.5 1)')); +-------+ | _col0 | +-------+ | 0.5 | +-------+
ST_Y
ST_Y(GEOMETRY) -> DOUBLE
返回Point的Y坐標(biāo)。
示例:
select ST_Y(ST_GeometryFromText('POINT (0.5 1)')); +-------+ | _col0 | +-------+ | 1.0 | +-------+
ST_Boundary
ST_Boundary(GEOMETRY) -> GEOMETRY
輸入一個(gè)幾何對(duì)象,然后以幾何對(duì)象形式返回其組合邊界。
示例:
select ST_asText(ST_Boundary(ST_GeometryFromText('POINT (0.5 1)'))); +-------------+ | _col0 | +-------------+ | POINT EMPTY | +-------------+ select ST_asText(ST_Boundary(ST_GeometryFromText('LINESTRING (0 0, 1 1, 1 2)'))); +---------------------------+ | _col0 | +---------------------------+ | MULTIPOINT ((0 0), (1 2)) | +---------------------------+ select ST_asText(ST_Boundary(ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'))); +-------------------------------------------------------------------------------------------------------------+ | _col0 | +-------------------------------------------------------------------------------------------------------------+ | MULTILINESTRING ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1), (-1 -1, -2 -1, -2 -2, -1 -2, -1 -1)) | +-------------------------------------------------------------------------------------------------------------+
ST_Envelope
ST_Envelope(GEOMETRY) -> GEOMETRY
以多邊形的形式返回幾何對(duì)象的最小邊界框。
示例:
select ST_asText(ST_Envelope(ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'))); +-------------------------------------------+ | _col0 | +-------------------------------------------+ | POLYGON ((-2 -2, 4 -2, 4 4, -2 4, -2 -2)) | +-------------------------------------------+
ST_Difference
ST_Difference(GEOMETRY, GEOMETRY) -> GEOMETRY
輸入兩個(gè)幾何對(duì)象,然后返回表示兩個(gè)源對(duì)象之差的幾何對(duì)象。
示例:
select ST_asText(ST_Difference( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTILINESTRING ((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1), (-1 -1, -2 -1, -2 -2, -1 -2, -1 -1))'))); +--------------------------------------------------------------------------------------------------------------+ | _col0 | +--------------------------------------------------------------------------------------------------------------+ | MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((-1 -1, -2 -1, -2 -2, -1 -2, -1 -1))) | +--------------------------------------------------------------------------------------------------------------+ select ST_asText(ST_Difference( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'))); +--------------------+ | _col0 | +--------------------+ | MULTIPOLYGON EMPTY | +--------------------+
ST_Distance
ST_Distance(GEOMETRY, GEOMETRY) -> DOUBLE
用于返回兩個(gè)幾何對(duì)象之間的距離。這一距離是兩個(gè)幾何對(duì)象的最近折點(diǎn)之間的距離。
示例:
select ST_Distance( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 0.0 | +-------+ select ST_Distance( ST_GeometryFromText('POINT(0 0)'), ST_GeometryFromText('POINT(1 1)')); +--------------------+ | _col0 | +--------------------+ | 1.4142135623730951 | +--------------------+
ST_ExteriorRing
ST_ExteriorRing(GEOMETRY) -> GEOMETRY
以L(fǎng)ine形式返回面的外部環(huán)。
示例:
select ST_asText(ST_ExteriorRing(ST_GeometryFromText('POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))'))); +--------------------------------------+ | _col0 | +--------------------------------------+ | LINESTRING (0 0, 4 0, 4 4, 0 4, 0 0) | +--------------------------------------+
ST_Intersection
ST_Intersection(GEOMETRY, GEOMETRY) -> GEOMETRY
以?xún)蓚€(gè)幾何對(duì)象作為輸入?yún)?shù),然后以二維幾何對(duì)象的形式返回交集。
示例:
select ST_asText(ST_Intersection( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'))); +--------------------------------------------------------------------------------------------------------------+ | _col0 | +--------------------------------------------------------------------------------------------------------------+ | MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1)), ((-1 -1, -2 -1, -2 -2, -1 -2, -1 -1))) | +--------------------------------------------------------------------------------------------------------------+ select ST_asText(ST_Intersection( ST_GeometryFromText('POINT(0 0)'), ST_GeometryFromText('POINT(1 1)'))); +--------------------+ | _col0 | +--------------------+ | MULTIPOLYGON EMPTY | +--------------------+
ST_SymDifference
ST_SymDifference(GEOMETRY, GEOMETRY) -> GEOMETRY
返回表示兩個(gè)幾何對(duì)象間的點(diǎn)集對(duì)稱(chēng)差異的幾何值對(duì)象。
示例:
select ST_asText(ST_SymDifference( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'))); +--------------------+ | _col0 | +--------------------+ | MULTIPOLYGON EMPTY | +--------------------+ select ST_asText(ST_SymDifference( ST_GeometryFromText('POINT(0 0)'), ST_GeometryFromText('POINT(1 1)'))); +---------------------------+ | _col0 | +---------------------------+ | MULTIPOINT ((0 0), (1 1)) | +---------------------------+
下圖的陰影部分顯示了對(duì)稱(chēng)差異的結(jié)果。對(duì)稱(chēng)差異為包括兩個(gè)表面的多表面圖形:其中一個(gè)表面包含位于正方形之內(nèi)、圓形之外的所有點(diǎn),另外一個(gè)表面包含位于圓形之內(nèi)、正方形之外的所有點(diǎn)。
ST_Contains
ST_Contains(GEOMETRY, GEOMETRY) -> BOOLEAN
輸入兩個(gè)幾何對(duì)象,判斷第一個(gè)對(duì)象是否完全包含第二個(gè)對(duì)象。
示例:
select ST_Contains( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 1 | +-------+ select ST_Contains( ST_GeometryFromText('POINT(0 0)'), ST_GeometryFromText('POINT(1 1)')); +-------+ | _col0 | +-------+ | 0 | +-------+
ST_Crosses
ST_Crosses(GEOMETRY, GEOMETRY) -> BOOLEAN
以?xún)蓚€(gè)幾何對(duì)象作為輸入,如果這兩個(gè)對(duì)象的交集生成的幾何對(duì)象的維度小于兩個(gè)源對(duì)象中的最大維度,則返回 1。交集對(duì)象所包含的點(diǎn)必須在兩個(gè)源幾何的內(nèi)部,并且不等于其中任何一個(gè)源對(duì)象。否則,返回 0。
示例:
select ST_Crosses( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_Crosses( ST_GeometryFromText('LINESTRING(0 0, 2 2)'), ST_GeometryFromText('LINESTRING(0 2, 2 0)')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_Disjoint
ST_Disjoint(GEOMETRY, GEOMETRY) -> BOOLEAN
輸入兩個(gè)幾何對(duì)象,判斷兩個(gè)幾何對(duì)象的交集是否為空集。
示例:
select ST_Disjoint( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_Disjoint( ST_GeometryFromText('LINESTRING(0 0, 2 2)'), ST_GeometryFromText('LINESTRING(0 2, 2 4)')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_Equals
ST_Equals(GEOMETRY, GEOMETRY) -> BOOLEAN
判斷兩個(gè)幾何對(duì)象是否完全相同。
示例:
select ST_Equals( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 1 | +-------+ select ST_Equals( ST_GeometryFromText('LINESTRING(0 0, 2 2)'), ST_GeometryFromText('LINESTRING(0 2, 2 4)')); +-------+ | _col0 | +-------+ | 0 | +-------+
ST_Intersects
ST_Intersects(GEOMETRY, GEOMETRY) -> BOOLEAN
判斷兩個(gè)幾何對(duì)象的交集是否不生成空集。
示例:
select ST_Intersects( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 1 | +-------+ select ST_Intersects( ST_GeometryFromText('LINESTRING(0 0, 2 2)'), ST_GeometryFromText('LINESTRING(0 2, 2 4)')); +-------+ | _col0 | +-------+ | 0 | +-------+
ST_Overlaps
ST_Overlaps(GEOMETRY, GEOMETRY) -> BOOLEAN
判斷兩個(gè)幾何對(duì)象的交集生成的幾何對(duì)象是否維度相同但不等于任一源對(duì)象。
示例:
select ST_Overlaps( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_Overlaps( ST_GeometryFromText('LINESTRING(1 1, 2 2)'), ST_GeometryFromText('LINESTRING(0 0, 1.5 1.5)')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_Relate
ST_Relate(GEOMETRY, GEOMETRY, VARCHAR) -> BOOLEAN
比較兩個(gè)幾何對(duì)象,判斷是否滿(mǎn)足“DE-9IM”模式(https://en.wikipedia.org/wiki/DE-9IM)矩陣字符串指定的條件。
示例:
select ST_Relate( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), '102101FF2'); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_Relate( ST_GeometryFromText('LINESTRING(1 1, 2 2)'), ST_GeometryFromText('LINESTRING(0 0, 1.5 1.5)'), '1*1***1**'); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_Touches
ST_Touches(GEOMETRY, GEOMETRY) -> BOOLEAN
判斷兩個(gè)幾何對(duì)象的公共點(diǎn)是否都不與兩個(gè)幾何對(duì)象的內(nèi)部相交。
示例:
select ST_Touches( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 0 | +-------+ select ST_Touches( ST_GeometryFromText('LINESTRING(1 1, 2 2)'), ST_GeometryFromText('LINESTRING(0 0, 1 1)')); +-------+ | _col0 | +-------+ | 1 | +-------+
ST_Within
ST_Within(GEOMETRY, GEOMETRY) -> BOOLEAN
判斷第一個(gè)幾何對(duì)象是否完全位于第二個(gè)幾何對(duì)象的范圍內(nèi)。
示例:
select ST_Within( ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))'), ST_GeometryFromText('MULTIPOLYGON (((0 0, 4 0, 4 4, 0 4, 0 0), (1 1, 2 1, 2 2, 1 2, 1 1)), ((-1 -1, -1 -2, -2 -2, -2 -1, -1 -1)))')); +-------+ | _col0 | +-------+ | 1 | +-------+ select ST_Within( ST_GeometryFromText('LINESTRING(1 1, 2 2)'), ST_GeometryFromText('LINESTRING(0 0, 1 1)')); +-------+ | _col0 | +-------+ | 0 | +-------+
ST_asBinary
ST_asBinary(GEOMETRY) -> VARBINARY
輸入一個(gè)幾何對(duì)象,然后返回其可識(shí)別的二進(jìn)制WKB數(shù)據(jù)。
ST_GeometryFromWKBHexString
ST_GeometryFromWKBHexString(VARCHAR) -> GEOMETRY
輸入WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。
示例:
select ST_ASTEXT(ST_GeometryFromWKBHexString('000000000140000000000000004010000000000000')); +-------------+ | _col0 | +-------------+ | POINT (2 4) | +-------------+
ST_pointFromWKBHexString
ST_pointFromWKBHexString(VARCHAR) -> GEOMETRY
輸入Point的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的Point幾何對(duì)象。
示例:
select ST_ASTEXT(ST_pointFromWKBHexString('000000000140000000000000004010000000000000')); +-------------+ | _col0 | +-------------+ | POINT (2 4) | +-------------+
ST_lineFromWKBHexString
ST_lineFromWKBHexString(VARCHAR) -> GEOMETRY
輸入Line的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的Line幾何對(duì)象。
ST_polyFromWKBHexString
ST_polyFromWKBHexString(VARCHAR) -> GEOMETRY
輸入Polygon的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的Polygon幾何對(duì)象。
ST_MPointFromWKBHexString
ST_MPointFromWKBHexString(VARCHAR) -> GEOMETRY
輸入MultiPoint的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的MultiPoint幾何對(duì)象。
示例:
SELECT ST_asText(ST_MPointFromWKBHexString('0104000000020000000101000000000000000000000000000000000000000101000000000000000000F03F0000000000000040')); +---------------------------+ | _col0 | +---------------------------+ | MULTIPOINT ((0 0), (1 2)) | +---------------------------+
ST_MLineFromWKBHexString
ST_MLineFromWKBHexString(VARCHAR) -> GEOMETRY
輸入MultiLine的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的MultiLine幾何對(duì)象。
ST_MPolyFromWKBHexString
ST_MPolyFromWKBHexString(VARCHAR) -> GEOMETRY
輸入MultiPolygon的WKB的HEX字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的MultiPolygon幾何對(duì)象。
ST_GeometryFromWKB
ST_GeometryFromWKB(VARBINARY) -> GEOMETRY
輸入WKB數(shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。
示例:
select ST_ASTEXT(ST_GeometryFromWKB(from_hex('000000000140000000000000004010000000000000'))); +-------------+ | _col0 | +-------------+ | POINT (2 4) | +-------------+
ST_pointFromWKB
ST_pointFromWKB(VARBINARY) -> GEOMETRY
輸入Point的WKB數(shù)據(jù),返回對(duì)應(yīng)的Point幾何對(duì)象。
示例:
select ST_ASTEXT(ST_pointFromWKB(from_hex('000000000140000000000000004010000000000000'))); +-------------+ | _col0 | +-------------+ | POINT (2 4) | +-------------+
ST_lineFromWKB
ST_lineFromWKB(VARBINARY) -> GEOMETRY
輸入Line的WKB數(shù)據(jù),返回對(duì)應(yīng)的Line幾何對(duì)象。
ST_polyFromWKB
ST_polyFromWKB(VARBINARY) -> GEOMETRY
輸入Polygon的WKB數(shù)據(jù),返回對(duì)應(yīng)的Polygon幾何對(duì)象。
ST_MPointFromWKB
ST_MPointFromWKB(VARBINARY) -> GEOMETRY
輸入MultiPoint的WKB數(shù)據(jù),返回對(duì)應(yīng)的MultiPoint幾何對(duì)象。
示例:
SELECT ST_asText(ST_MPointFromWKB(from_hex('0104000000020000000101000000000000000000000000000000000000000101000000000000000000F03F0000000000000040'))); +---------------------------+ | _col0 | +---------------------------+ | MULTIPOINT ((0 0), (1 2)) | +---------------------------+
ST_MLineFromWKB
ST_MLineFromWKB(VARBINARY) -> GEOMETRY
輸入MultiLine的WKB數(shù)據(jù),返回對(duì)應(yīng)的MultiLine幾何對(duì)象。
ST_MPolyFromWKB
ST_MPolyFromWKB(VARBINARY) -> GEOMETRY
輸入MultiPolygon的WKB數(shù)據(jù),返回對(duì)應(yīng)的MultiPolygon幾何對(duì)象。
ST_GeometryFromGeoJson
ST_GeometryFromGeoJson(VARCHAR) -> GEOMETRY
輸入GeoJson的字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。
ST_GeometryFromJson
ST_GeometryFromJson(VARCHAR) -> GEOMETRY
輸入ESRI Geometry Object Json的字符串?dāng)?shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。
ST_asGeoJson
ST_asGeoJson(GEOMETRY) -> VARCHAR
把幾何對(duì)象轉(zhuǎn)成GeoJson格式輸出。
示例:
SELECT ST_asGeoJson(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-----------------------------------------------------------------------------------------------+ | _col0 | +-----------------------------------------------------------------------------------------------+ | {"type":"MultiLineString","coordinates":[[[0,0],[1,1],[1,2]],[[2,3],[3,2],[5,4]]],"crs":null} | +-----------------------------------------------------------------------------------------------+
ST_asJson
ST_asJson(GEOMETRY) -> VARCHAR
把幾何對(duì)象轉(zhuǎn)成ESRI Geometry Object Json格式輸出。
示例:
SELECT ST_asJson(ST_GeometryFromText('MULTILINESTRING ((0 0, 1 1, 1 2), (2 3, 3 2, 5 4))')); +-----------------------------------------------------+ | _col0 | +-----------------------------------------------------+ | {"paths":[[[0,0],[1,1],[1,2]],[[2,3],[3,2],[5,4]]]} | +-----------------------------------------------------+
ST_GeometryFromEsriShape
ST_GeometryFromEsriShape(VARBINARY) -> GEOMETRY
輸入ESRI Shape的二進(jìn)制數(shù)據(jù),返回對(duì)應(yīng)的幾何對(duì)象。
示例:
SELECT california_counties.name, COUNT(*) cnt FROM california_counties CROSS JOIN earthquakes WHERE ST_CONTAINS (ST_GeometryFromesrishape(california_counties.boundaryshape), ST_POINT(earthquakes.longitude, earthquakes.latitude)) GROUP BY california_counties.name ORDER BY cnt DESC, california_counties.name; +-----------------+------+ | name | cnt | +-----------------+------+ | San Benito | 8 | | San Bernardino | 7 | | Riverside | 6 | | Inyo | 5 | | Imperial | 3 | | San Diego | 2 | | Kern | 1 | | Kings | 1 | | Monterey | 1 | | San Luis Obispo | 1 | | Santa Clara | 1 | | Ventura | 1 | +-----------------+------+
UDF_SYS_GEO_IN_CYCLE
UDF_SYS_GEO_IN_CYCLE(longitude, latitude, point, radius) -> BOOLEAN 第一個(gè)參數(shù)為經(jīng)度列名稱(chēng), 類(lèi)型FLOAT/DOUBLE 第二個(gè)參數(shù)為緯度列名稱(chēng), 類(lèi)型FLOAT/DOUBLE 第三個(gè)參數(shù)為圓圈中心點(diǎn)的位置,格式=>'經(jīng)度,維度', =>'120.85979,30.011984' 第四個(gè)參數(shù)為圓圈的半徑,單位米
判斷l(xiāng)ongitude、latitude的點(diǎn)是否在以中心點(diǎn)point為圓心,半徑為radius的圓內(nèi)。
示例:
SELECT count(*) as cnt FROM earthquakes WHERE UDF_SYS_GEO_IN_CYCLE(longitude,latitude, '120.85979,30.011984', 5000000000000) = true; +------+ | cnt | +------+ | 2858 | +------+
UDF_SYS_GEO_IN_RECTANGLE
UDF_SYS_GEO_IN_RECTANGLE(longitude, latitude, pointA, pointB) -> BOOLEAN 第一個(gè)參數(shù)為經(jīng)度列名稱(chēng), 類(lèi)型FLOAT/DOUBLE 第二個(gè)參數(shù)為緯度列名稱(chēng), 類(lèi)型FLOAT/DOUBLE 第三個(gè)參數(shù)為矩形的左下角坐標(biāo),格式=>'經(jīng)度,維度', =>'120.85979,30.011984' 第四個(gè)參數(shù)為矩形的右上角坐標(biāo),格式=>'經(jīng)度,維度', =>'120.88450,31.21011'
判斷l(xiāng)ongitude、latitude的點(diǎn)是否在以2個(gè)斜角點(diǎn)構(gòu)成的矩形內(nèi)。
示例:
SELECT count(*) as cnt FROM earthquakes WHERE UDF_SYS_GEO_IN_RECTANGLE(longitude, latitude, '69.037,36.5759', '142.018,67.8713')=true; +------+ | cnt | +------+ | 55 | +------+
UDF_SYS_GEO_DISTANCE
UDF_SYS_GEO_DISTANCE(longitude, latitude, pointA) -> INTEGER 第一個(gè)參數(shù)為經(jīng)度列名稱(chēng), 類(lèi)型FLOAT/DOUBLE 第二個(gè)參數(shù)為緯度列名稱(chēng), 類(lèi)型FLOAT/DOUBLE 第三個(gè)參數(shù)為固定坐標(biāo)點(diǎn)的經(jīng)緯度,格式=>'經(jīng)度,維度', =>'120.85979,30.011984'
求longitude、latitude的點(diǎn)和pointA點(diǎn)的距離,單位:米。
示例:
SELECT count(*) as cnt FROM earthquakes WHERE UDF_SYS_GEO_DISTANCE(longitude, latitude, '69.037,36.5759') > 10000; +------+ | cnt | +------+ | 2857 | +------+
看完上述內(nèi)容,你們掌握Data Lake Analytics的Geospatial分析函數(shù)怎么理解的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。