Skip to content

Commit 3dc705c

Browse files
authored
docs: Add Geography functions doc (#3076)
* docs: Add Geography functions doc * fix
1 parent 53f3904 commit 3dc705c

38 files changed

Lines changed: 941 additions & 69 deletions

docs/en/sql-reference/20-sql-functions/09-geospatial-functions/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Databend ships with two complementary sets of geospatial capabilities: PostGIS-s
99
| Function | Description | Example |
1010
|----------|-------------|---------|
1111
| [ST_MAKEGEOMPOINT](st-makegeompoint.md) / [ST_GEOM_POINT](st-geom-point.md) | Construct a Point geometry | `ST_MAKEGEOMPOINT(-122.35, 37.55)``POINT(-122.35 37.55)` |
12+
| [ST_MAKEPOINT](st-makepoint.md) / [ST_POINT](st-point.md) | Construct a Point geography | `ST_MAKEPOINT(-122.35, 37.55)``POINT(-122.35 37.55)` |
1213
| [ST_MAKELINE](st-makeline.md) / [ST_MAKE_LINE](st-make-line.md) | Create a LineString from points | `ST_MAKELINE(ST_MAKEGEOMPOINT(-122.35, 37.55), ST_MAKEGEOMPOINT(-122.40, 37.60))``LINESTRING(-122.35 37.55, -122.40 37.60)` |
1314
| [ST_MAKEPOLYGON](st-makepolygon.md) | Create a Polygon from a closed LineString | `ST_MAKEPOLYGON(ST_MAKELINE(...))``POLYGON(...)` |
1415
| [ST_POLYGON](st-polygon.md) | Create a Polygon from coordinate rings | `ST_POLYGON(...)``POLYGON(...)` |
@@ -21,9 +22,14 @@ Databend ships with two complementary sets of geospatial capabilities: PostGIS-s
2122
| [ST_GEOMETRYFROMWKB](st-geometryfromwkb.md) / [ST_GEOMFROMWKB](st-geomfromwkb.md) | Convert WKB to geometry | `ST_GEOMETRYFROMWKB(...)``POINT(...)` |
2223
| [ST_GEOMETRYFROMEWKT](st-geometryfromewkt.md) / [ST_GEOMFROMEWKT](st-geomfromewkt.md) | Convert EWKT to geometry | `ST_GEOMETRYFROMEWKT('SRID=4326;POINT(-122.35 37.55)')``POINT(-122.35 37.55)` |
2324
| [ST_GEOMETRYFROMEWKB](st-geometryfromewkb.md) / [ST_GEOMFROMEWKB](st-geomfromewkb.md) | Convert EWKB to geometry | `ST_GEOMETRYFROMEWKB(...)``POINT(...)` |
25+
| [ST_GEOGRAPHYFROMWKT](st-geographyfromwkt.md) / [ST_GEOGFROMWKT](st-geogfromwkt.md) | Convert WKT/EWKT to geography | `ST_GEOGRAPHYFROMWKT('POINT(-122.35 37.55)')``POINT(-122.35 37.55)` |
26+
| [ST_GEOGRAPHYFROMWKB](st-geographyfromwkb.md) / [ST_GEOGFROMWKB](st-geogfromwkb.md) | Convert WKB/EWKB to geography | `ST_GEOGRAPHYFROMWKB(...)``POINT(...)` |
2427
| [ST_GEOMFROMGEOHASH](st-geomfromgeohash.md) | Convert GeoHash to geometry | `ST_GEOMFROMGEOHASH('9q8yyk8')``POLYGON(...)` |
2528
| [ST_GEOMPOINTFROMGEOHASH](st-geompointfromgeohash.md) | Convert GeoHash to Point geometry | `ST_GEOMPOINTFROMGEOHASH('9q8yyk8')``POINT(...)` |
29+
| [ST_GEOGFROMGEOHASH](st-geogfromgeohash.md) | Convert GeoHash to geography polygon | `ST_GEOGFROMGEOHASH('9q8yyk8')``POLYGON(...)` |
30+
| [ST_GEOGPOINTFROMGEOHASH](st-geogpointfromgeohash.md) | Convert GeoHash to geography point | `ST_GEOGPOINTFROMGEOHASH('9q8yyk8')``POINT(...)` |
2631
| [TO_GEOMETRY](to-geometry.md) | Parse various formats into geometry | `TO_GEOMETRY('POINT(-122.35 37.55)')``POINT(-122.35 37.55)` |
32+
| [TO_GEOGRAPHY](to-geography.md) / [TRY_TO_GEOGRAPHY](to-geography.md) | Parse various formats into geography | `TO_GEOGRAPHY('POINT(-122.35 37.55)')``POINT(-122.35 37.55)` |
2733

2834
## Geometry Output
2935

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: ST_AREA
3+
---
4+
import FunctionDescription from '@site/src/components/FunctionDescription';
5+
6+
<FunctionDescription description="Introduced or updated: v1.2.555"/>
7+
8+
Returns the area of a GEOMETRY or GEOGRAPHY object. For GEOMETRY inputs, the function uses planar area based on the [shoelace formula](https://en.wikipedia.org/wiki/Shoelace_formula). For GEOGRAPHY inputs, the function measures geodesic area on an ellipsoidal model of the earth using the method described in [Karney (2013)](https://arxiv.org/pdf/1109.4448.pdf).
9+
10+
## Syntax
11+
12+
```sql
13+
ST_AREA(<geometry_or_geography>)
14+
```
15+
16+
## Arguments
17+
18+
| Arguments | Description |
19+
|---------------------------|-----------------------------------------------------------------|
20+
| `<geometry_or_geography>` | The argument must be an expression of type GEOMETRY or GEOGRAPHY. |
21+
22+
## Return Type
23+
24+
Double.
25+
26+
## Examples
27+
28+
### GEOMETRY examples
29+
30+
```sql
31+
SELECT
32+
ST_AREA(
33+
TO_GEOMETRY('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
34+
) AS area
35+
36+
┌──────┐
37+
│ area │
38+
├──────┤
39+
1.0
40+
└──────┘
41+
```
42+
43+
### GEOGRAPHY examples
44+
45+
```sql
46+
SELECT
47+
ST_AREA(
48+
TO_GEOGRAPHY('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
49+
) AS area
50+
51+
╭────────────────────╮
52+
│ area │
53+
├────────────────────┤
54+
12308778361.469452
55+
╰────────────────────╯
56+
```

docs/en/sql-reference/20-sql-functions/09-geospatial-functions/st-asewkb.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,28 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
55

66
<FunctionDescription description="Introduced or updated: v1.2.436"/>
77

8-
Converts a GEOMETRY object into a [EWKB(extended well-known-binary)](https://postgis.net/docs/ST_GeomFromEWKB.html) format representation.
8+
Converts a GEOMETRY or GEOGRAPHY object into a [EWKB(extended well-known-binary)](https://postgis.net/docs/ST_GeomFromEWKB.html) format representation.
99

1010
## Syntax
1111

1212
```sql
13-
ST_ASEWKB(<geometry>)
13+
ST_ASEWKB(<geometry_or_geography>)
1414
```
1515

1616
## Arguments
1717

1818
| Arguments | Description |
1919
|--------------|------------------------------------------------------|
20-
| `<geometry>` | The argument must be an expression of type GEOMETRY. |
20+
| `<geometry_or_geography>` | The argument must be an expression of type GEOMETRY or GEOGRAPHY. |
2121

2222
## Return Type
2323

2424
Binary.
2525

2626
## Examples
2727

28+
### GEOMETRY examples
29+
2830
```sql
2931
SELECT
3032
ST_ASEWKB(
@@ -52,3 +54,20 @@ SELECT
5254
│ 0101000020E61000006666666666965EC06666666666C64240 │
5355
└────────────────────────────────────────────────────┘
5456
```
57+
58+
### GEOGRAPHY examples
59+
60+
```sql
61+
SELECT
62+
ST_ASEWKB(
63+
ST_GEOGFROMWKT(
64+
'SRID=4326;POINT(-122.35 37.55)'
65+
)
66+
) AS pipeline_ewkb;
67+
68+
╭────────────────────────────────────────────────────╮
69+
│ pipeline_ewkb │
70+
├────────────────────────────────────────────────────┤
71+
│ 0101000020E61000006666666666965EC06666666666C64240 │
72+
╰────────────────────────────────────────────────────╯
73+
```

docs/en/sql-reference/20-sql-functions/09-geospatial-functions/st-asewkt.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,28 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
55

66
<FunctionDescription description="Introduced or updated: v1.2.436"/>
77

8-
Converts a GEOMETRY object into a [EWKT(extended well-known-text)](https://postgis.net/docs/ST_GeomFromEWKT.html) format representation.
8+
Converts a GEOMETRY or GEOGRAPHY object into a [EWKT(extended well-known-text)](https://postgis.net/docs/ST_GeomFromEWKT.html) format representation.
99

1010
## Syntax
1111

1212
```sql
13-
ST_ASEWKT(<geometry>)
13+
ST_ASEWKT(<geometry_or_geography>)
1414
```
1515

1616
## Arguments
1717

1818
| Arguments | Description |
1919
|--------------|------------------------------------------------------|
20-
| `<geometry>` | The argument must be an expression of type GEOMETRY. |
20+
| `<geometry_or_geography>` | The argument must be an expression of type GEOMETRY or GEOGRAPHY. |
2121

2222
## Return Type
2323

2424
String.
2525

2626
## Examples
2727

28+
### GEOMETRY examples
29+
2830
```sql
2931
SELECT
3032
ST_ASEWKT(
@@ -52,3 +54,20 @@ SELECT
5254
│ SRID=4326;POINT(-122.35 37.55) │
5355
└────────────────────────────────┘
5456
```
57+
58+
### GEOGRAPHY examples
59+
60+
```sql
61+
SELECT
62+
ST_ASEWKT(
63+
ST_GEOGFROMWKT(
64+
'SRID=4326;POINT(-122.35 37.55)'
65+
)
66+
) AS pipeline_ewkt;
67+
68+
╭────────────────────────────────╮
69+
│ pipeline_ewkt │
70+
├────────────────────────────────┤
71+
│ SRID=4326;POINT(-122.35 37.55) │
72+
╰────────────────────────────────╯
73+
```

docs/en/sql-reference/20-sql-functions/09-geospatial-functions/st-asgeojson.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,28 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
55

66
<FunctionDescription description="Introduced or updated: v1.2.427"/>
77

8-
Converts a GEOMETRY object into a [GeoJSON](https://geojson.org/) representation.
8+
Converts a GEOMETRY or GEOGRAPHY object into a [GeoJSON](https://geojson.org/) representation.
99

1010
## Syntax
1111

1212
```sql
13-
ST_ASGEOJSON(<geometry>)
13+
ST_ASGEOJSON(<geometry_or_geography>)
1414
```
1515

1616
## Arguments
1717

1818
| Arguments | Description |
1919
|--------------|------------------------------------------------------|
20-
| `<geometry>` | The argument must be an expression of type GEOMETRY. |
20+
| `<geometry_or_geography>` | The argument must be an expression of type GEOMETRY or GEOGRAPHY. |
2121

2222
## Return Type
2323

2424
Variant.
2525

2626
## Examples
2727

28+
### GEOMETRY examples
29+
2830
```sql
2931
SELECT
3032
ST_ASGEOJSON(
@@ -38,4 +40,20 @@ SELECT
3840
├─────────────────────────────────────────────────────────────────────────┤
3941
│ {"coordinates":[[400000,6000000],[401000,6010000]],"type":"LineString"} │
4042
└─────────────────────────────────────────────────────────────────────────┘
41-
```
43+
```
44+
45+
### GEOGRAPHY examples
46+
47+
```sql
48+
SELECT
49+
ST_ASGEOJSON(
50+
ST_GEOGFROMWKT(
51+
'SRID=4326;POINT(-122.35 37.55)'
52+
)
53+
) AS pipeline_geojson;
54+
55+
╭────────────────────────────────────────────────╮
56+
│ pipeline_geojson │
57+
├────────────────────────────────────────────────┤
58+
│ {"coordinates":[-122.35,37.55],"type":"Point"} │
59+
╰────────────────────────────────────────────────╯```

docs/en/sql-reference/20-sql-functions/09-geospatial-functions/st-aswkb.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
55

66
<FunctionDescription description="Introduced or updated: v1.2.436"/>
77

8-
Converts a GEOMETRY object into a [WKB(well-known-binary)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Well-known_binary) format representation.
8+
Converts a GEOMETRY or GEOGRAPHY object into a [WKB(well-known-binary)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry#Well-known_binary) format representation.
99

1010
## Syntax
1111

1212
```sql
13-
ST_ASWKB(<geometry>)
13+
ST_ASWKB(<geometry_or_geography>)
1414
```
1515

1616
## Aliases
@@ -21,14 +21,16 @@ ST_ASWKB(<geometry>)
2121

2222
| Arguments | Description |
2323
|--------------|------------------------------------------------------|
24-
| `<geometry>` | The argument must be an expression of type GEOMETRY. |
24+
| `<geometry_or_geography>` | The argument must be an expression of type GEOMETRY or GEOGRAPHY. |
2525

2626
## Return Type
2727

2828
Binary.
2929

3030
## Examples
3131

32+
### GEOMETRY examples
33+
3234
```sql
3335
SELECT
3436
ST_ASWKB(
@@ -56,3 +58,20 @@ SELECT
5658
│ 01010000006666666666965EC06666666666C64240 │
5759
└────────────────────────────────────────────┘
5860
```
61+
62+
### GEOGRAPHY examples
63+
64+
```sql
65+
SELECT
66+
ST_ASWKB(
67+
ST_GEOGFROMWKT(
68+
'SRID=4326;POINT(-122.35 37.55)'
69+
)
70+
) AS pipeline_wkb;
71+
72+
╭────────────────────────────────────────────╮
73+
│ pipeline_wkb │
74+
├────────────────────────────────────────────┤
75+
│ 01010000006666666666965EC06666666666C64240 │
76+
╰────────────────────────────────────────────╯
77+
```

docs/en/sql-reference/20-sql-functions/09-geospatial-functions/st-aswkt.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
55

66
<FunctionDescription description="Introduced or updated: v1.2.436"/>
77

8-
Converts a GEOMETRY object into a [WKT(well-known-text)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) format representation.
8+
Converts a GEOMETRY or GEOGRAPHY object into a [WKT(well-known-text)](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) format representation.
99

1010
## Syntax
1111

1212
```sql
13-
ST_ASWKT(<geometry>)
13+
ST_ASWKT(<geometry_or_geography>)
1414
```
1515

1616
## Aliases
@@ -21,14 +21,16 @@ ST_ASWKT(<geometry>)
2121

2222
| Arguments | Description |
2323
|--------------|------------------------------------------------------|
24-
| `<geometry>` | The argument must be an expression of type GEOMETRY. |
24+
| `<geometry_or_geography>` | The argument must be an expression of type GEOMETRY or GEOGRAPHY. |
2525

2626
## Return Type
2727

2828
String.
2929

3030
## Examples
3131

32+
### GEOMETRY examples
33+
3234
```sql
3335
SELECT
3436
ST_ASWKT(
@@ -56,3 +58,20 @@ SELECT
5658
POINT(-122.35 37.55) │
5759
└──────────────────────┘
5860
```
61+
62+
### GEOGRAPHY examples
63+
64+
```sql
65+
SELECT
66+
ST_ASWKT(
67+
ST_GEOGFROMWKT(
68+
'SRID=4326;POINT(-122.35 37.55)'
69+
)
70+
) AS pipeline_wkt;
71+
72+
╭──────────────────────╮
73+
│ pipeline_wkt │
74+
├──────────────────────┤
75+
POINT(-122.35 37.55) │
76+
╰──────────────────────╯
77+
```

0 commit comments

Comments
 (0)