You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sedona.apache.org by ji...@apache.org on 2024/04/27 23:49:11 UTC
(sedona) 01/01: Update SedonaSnow docs
This is an automated email from the ASF dual-hosted git repository.
jiayu pushed a commit to branch fix-docs
in repository https://gitbox.apache.org/repos/asf/sedona.git
commit 6365680b8136ea76455aa098ca71d69ce39f12e1
Author: Jia Yu <ji...@apache.org>
AuthorDate: Sat Apr 27 16:49:00 2024 -0700
Update SedonaSnow docs
---
.../api/snowflake/vector-data/AggregateFunction.md | 33 +++++++++--
docs/api/snowflake/vector-data/Function.md | 69 ++++++++++++----------
2 files changed, 64 insertions(+), 38 deletions(-)
diff --git a/docs/api/snowflake/vector-data/AggregateFunction.md b/docs/api/snowflake/vector-data/AggregateFunction.md
index 43e4de154..bfb3b5c8b 100644
--- a/docs/api/snowflake/vector-data/AggregateFunction.md
+++ b/docs/api/snowflake/vector-data/AggregateFunction.md
@@ -10,13 +10,20 @@ Format: `ST_Envelope_Aggr (A:geometryColumn)`
SQL example:
```sql
-SELECT ST_Envelope_Aggr(ST_GeomFromText('MULTIPOINT(1.1 101.1,2.1 102.1,3.1 103.1,4.1 104.1,5.1 105.1,6.1 106.1,7.1 107.1,8.1 108.1,9.1 109.1,10.1 110.1)'))
+WITH src_tbl AS (
+ SELECT sedona.ST_GeomFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))') AS geom
+ UNION
+ SELECT sedona.ST_GeomFromText('POLYGON ((0.5 0.5, 0.5 1.5, 1.5 1.5, 1.5 0.5, 0.5 0.5))') AS geom
+)
+SELECT sedona.ST_AsText(envelope)
+FROM src_tbl,
+ TABLE(sedona.ST_Envelope_Aggr(src_tbl.geom) OVER (PARTITION BY 1));
```
Output:
```
-POLYGON ((1.1 101.1, 1.1 120.1, 20.1 120.1, 20.1 101.1, 1.1 101.1))
+POLYGON ((0 0, 0 1.5, 1.5 1.5, 1.5 0, 0 0))
```
## ST_Intersection_Aggr
@@ -28,13 +35,20 @@ Format: `ST_Intersection_Aggr (A:geometryColumn)`
SQL example:
```sql
-SELECT ST_Intersection_Aggr(ST_GeomFromText('MULTIPOINT(1.1 101.1,2.1 102.1,3.1 103.1,4.1 104.1,5.1 105.1,6.1 106.1,7.1 107.1,8.1 108.1,9.1 109.1,10.1 110.1)'))
+WITH src_tbl AS (
+ SELECT sedona.ST_GeomFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))') AS geom
+ UNION
+ SELECT sedona.ST_GeomFromText('POLYGON ((0.5 0.5, 0.5 1.5, 1.5 1.5, 1.5 0.5, 0.5 0.5))') AS geom
+)
+SELECT sedona.ST_AsText(intersected)
+FROM src_tbl,
+ TABLE(sedona.ST_Intersection_Aggr(src_tbl.geom) OVER (PARTITION BY 1));
```
Output:
```
-MULTIPOINT ((1.1 101.1), (2.1 102.1), (3.1 103.1), (4.1 104.1), (5.1 105.1), (6.1 106.1), (7.1 107.1), (8.1 108.1), (9.1 109.1), (10.1 110.1))
+POLYGON ((0.5 1, 1 1, 1 0.5, 0.5 0.5, 0.5 1))
```
## ST_Union_Aggr
@@ -46,11 +60,18 @@ Format: `ST_Union_Aggr (A:geometryColumn)`
SQL example:
```sql
-SELECT ST_Union_Aggr(ST_GeomFromText('MULTIPOINT(1.1 101.1,2.1 102.1,3.1 103.1,4.1 104.1,5.1 105.1,6.1 106.1,7.1 107.1,8.1 108.1,9.1 109.1,10.1 110.1)'))
+WITH src_tbl AS (
+ SELECT sedona.ST_GeomFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))') AS geom
+ UNION
+ SELECT sedona.ST_GeomFromText('POLYGON ((0.5 0.5, 0.5 1.5, 1.5 1.5, 1.5 0.5, 0.5 0.5))') AS geom
+)
+SELECT sedona.ST_AsText(unioned)
+FROM src_tbl,
+ TABLE(sedona.ST_Union_Aggr(src_tbl.geom) OVER (PARTITION BY 1));
```
Output:
```
-MULTIPOINT ((1.1 101.1), (2.1 102.1), (3.1 103.1), (4.1 104.1), (5.1 105.1), (6.1 106.1), (7.1 107.1), (8.1 108.1), (9.1 109.1), (10.1 110.1))
+POLYGON ((0 0, 0 1, 0.5 1, 0.5 1.5, 1.5 1.5, 1.5 0.5, 1 0.5, 1 0, 0 0))
```
diff --git a/docs/api/snowflake/vector-data/Function.md b/docs/api/snowflake/vector-data/Function.md
index b8df7cd1a..6f02aaed1 100644
--- a/docs/api/snowflake/vector-data/Function.md
+++ b/docs/api/snowflake/vector-data/Function.md
@@ -542,48 +542,38 @@ Output: `POINT(131.59149149528952 101.89887534906197)`
## ST_Collect
-Introduction: Returns MultiGeometry object based on a geometry column.
-
-Format
+Introduction:
-`ST_Collect(*geom: geometry)`
+Build an appropriate `Geometry`, `MultiGeometry`, or `GeometryCollection` to contain the `Geometry`s in it. For example:
-Example:
+- If `geomList` contains a single `Polygon`, the `Polygon` is returned.
+- If `geomList` contains several `Polygon`s, a `MultiPolygon` is returned.
+- If `geomList` contains some `Polygon`s and some `LineString`s, a `GeometryCollection` is returned.
+- If `geomList` is empty, an empty `GeometryCollection` is returned.
-```SQL
-SELECT ST_Collect(
- tbl.geom) AS geom
-```
+Note that this method does not "flatten" Geometries in the input, and hence if any MultiGeometries are contained in the input, a GeometryCollection containing them will be returned.
-Result:
+Format
-```
-+---------------------------------------------------------------+
-|geom |
-+---------------------------------------------------------------+
-|MULTIPOINT ((21.427834 52.042576573), (45.342524 56.342354355))|
-+---------------------------------------------------------------+
-```
+`ST_Collect(*geom: geometry)`
Example:
```SQL
-SELECT ST_Collect(
- Array(
- ST_GeomFromText('POINT(21.427834 52.042576573)'),
- ST_GeomFromText('POINT(45.342524 56.342354355)')
- )
-) AS geom
+WITH src_tbl AS (
+ SELECT sedona.ST_GeomFromText('POINT (40 10)') AS geom
+ UNION
+ SELECT sedona.ST_GeomFromText('LINESTRING (0 5, 0 10)') AS geom
+)
+SELECT sedona.ST_AsText(collection)
+FROM src_tbl,
+ TABLE(sedona.ST_Collect(src_tbl.geom) OVER (PARTITION BY 1));
```
Result:
```
-+---------------------------------------------------------------+
-|geom |
-+---------------------------------------------------------------+
-|MULTIPOINT ((21.427834 52.042576573), (45.342524 56.342354355))|
-+---------------------------------------------------------------+
+GEOMETRYCOLLECTION (POINT (40 10), LINESTRING (0 5, 0 10))
```
## ST_CollectionExtract
@@ -821,17 +811,25 @@ Output: `544430.9411996207`
## ST_Dump
-Introduction: This is an aggregate function that takes a column of geometries as input, and returns a single GeometryCollection of all these geometries.
+Introduction: This function takes a GeometryCollection/Multi Geometry object and returns a set of geometries containing the individual geometries that make up the input geometry. The function is useful for breaking down a GeometryCollection/Multi Geometry into its constituent geometries.
Format: `ST_Dump(geom: geometry)`
SQL example:
```SQL
-SELECT ST_Dump(tbl.geom)
+SELECT sedona.ST_AsText(geom)
+FROM table(sedona.ST_Dump(sedona.ST_GeomFromText('MULTIPOINT ((10 40), (40 30), (20 20), (30 10))')));
```
-Output: `GeometryCollection ( (10 40), (40 30), (20 20), (30 10) )`
+Output:
+
+```
+POINT (10 40)
+POINT (40 30)
+POINT (20 20)
+POINT (30 10)
+```
## ST_DumpPoints
@@ -1628,7 +1626,14 @@ Format: `ST_MinimumBoundingRadius(geom: geometry)`
SQL example:
```SQL
-SELECT ST_MinimumBoundingRadius(ST_GeomFromText('POLYGON((1 1,0 0, -1 1, 1 1))'))
+SELECT sedona.ST_AsText(center), radius
+FROM table(sedona.ST_MinimumBoundingRadius(sedona.ST_GeomFromText('POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))')))
+```
+
+Result:
+
+```
+POINT (0.5 0.5), 0.7071067811865476
```
## ST_Multi