Skip to content

Commit db0116a

Browse files
committed
Update sql-reference in spatial-extension-bq
1 parent 05928c7 commit db0116a

File tree

9 files changed

+466
-54
lines changed

9 files changed

+466
-54
lines changed

app/content/spatial-extension-bq/_index.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ cascade:
2727
- "placekey"
2828
- "random"
2929
- "data"
30-
- "transformation"
30+
- "constructors"
31+
- "transformations"
32+
- "measurements"
33+
- "clustering"
3134
---
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## clustering
2+
3+
<div class="badge core"></div>
4+
5+
### ST_CLUSTERKMEANS
6+
7+
{{% bannerNote type="code" %}}
8+
clustering.ST_CLUSTERKMEANS(geog, numberOfClusters)
9+
{{%/ bannerNote %}}
10+
11+
**Description**
12+
13+
Takes a set of points and partition them into clusters using the k-mean. It uses the k-means algorithm. Returns an array with the cluster index for each of the input features. https://turfjs.org/docs/#clustersKmeans
14+
15+
* `geog`: `ARRAY<GEOGRAPHY>` points to be clustered.
16+
* `numberOfClusters`: `INT64`|`NULL` numberOfClusters that will be generated. If `NULL` the default value `Math.sqrt(<NUMBER OF POINTS>/2)` is used.
17+
18+
**Return type**
19+
20+
`ARRAY<INT64>`
21+
22+
**Example**
23+
24+
```sql
25+
SELECT bqcarto.clustering.ST_CLUSTERKMEANS([ST_GEOGPOINT(0, 0), ST_GEOGPOINT(0, 1), ST_GEOGPOINT(5, 0), ST_GEOGPOINT(1, 0)], 2);
26+
-- [1, 1, 0, 1]
27+
```
28+
29+
### VERSION
30+
31+
{{% bannerNote type="code" %}}
32+
clustering.VERSION()
33+
{{%/ bannerNote %}}
34+
35+
**Description**
36+
37+
Returns the current version of the clustering module.
38+
39+
**Return type**
40+
41+
`STRING`
42+
43+
**Example**
44+
45+
```sql
46+
SELECT bqcarto.clustering.VERSION();
47+
-- 1.0.0
48+
```
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
## constructors
2+
3+
<div class="badge core"></div>
4+
5+
This module contains functions that create geographies from coordinates or already existing geographies.
6+
7+
### ST_BEZIERSPLINE
8+
9+
{{% bannerNote type="code" %}}
10+
constructors.ST_BEZIERSPLINE(geog, resolution, sharpness)
11+
{{%/ bannerNote %}}
12+
13+
**Description**
14+
15+
Takes a line and returns a curved version by applying a Bezier spline algorithm. https://turfjs.org/docs/#bezierSpline
16+
17+
* `geog`: `GEOGRAPHY` input LineString.
18+
* `resolution`: `INT64`|`NULL` time in milliseconds between points. If `NULL` the default value `10000` is used.
19+
* `sharpness`: `FLOAT64`|`NULL` a measure of how curvy the path should be between splines. If `NULL` the default value `0.85` is used.
20+
21+
```sql
22+
SELECT bqcarto.constructors.ST_BEZIERSPLINE(ST_GEOGFROMTEXT("LINESTRING (-76.091308 18.427501,-76.695556 18.729501,-76.552734 19.40443,-74.61914 19.134789,-73.652343 20.07657,-73.157958 20.210656)"), 10000, 0.9);
23+
-- LINESTRING(-76.091308 18.427501, -76.0916216712943 ...
24+
```
25+
26+
### ST_MAKEELLIPSE
27+
28+
{{% bannerNote type="code" %}}
29+
constructors.ST_MAKEELLIPSE(geog, xSemiAxis, ySemiAxis, angle, units, steps)
30+
{{%/ bannerNote %}}
31+
32+
**Description**
33+
34+
Takes a Point and calculates the ellipse polygon given two semi-axes expressed in variable units and steps for precision. https://github.com/Turfjs/turf/tree/master/packages/turf-ellipse
35+
36+
* `center`: `GEOGRAPHY` center point.
37+
* `xSemiAxis`: `FLOAT64` semi (major) axis of the ellipse along the x-axis.
38+
* `ySemiAxis`: `FLOAT64` semi (minor) axis of the ellipse along the y-axis.
39+
* `angle`: `FLOAT64`|`NULL` angle of rotation (along the vertical axis), from North in decimal degrees, negative clockwise. If `NULL` the default value `0` is used.
40+
* `units`: `STRING`|`NULL` any of the options supported by turf units: miles, kilometers, and degrees. If `NULL`the default value `kilometers` is used.
41+
* `steps`: `INT64`|`NULL` number of steps. If `NULL` the default value `64` is used.
42+
43+
```sql
44+
SELECT bqcarto.constructors.ST_MAKEELLIPSE(ST_GEOGPOINT(-73.9385,40.6643), 5, 3, -30, "miles", 80);
45+
-- POLYGON((-73.8558575786687 40.7004828957859 ...
46+
```
47+
48+
### ST_MAKEENVELOPE
49+
50+
{{% bannerNote type="code" %}}
51+
constructors.ST_MAKEENVELOPE(xmin, ymin, xma, ymax)
52+
{{%/ bannerNote %}}
53+
54+
**Description**
55+
Creates a rectangular Polygon from the minimum and maximum values for X and Y.
56+
57+
58+
* `xmin`: `FLOAT64` minimum value for X.
59+
* `ymin`: `FLOAT64` minimum value for Y.
60+
* `xmax`: `FLOAT64` maximum value for X.
61+
* `ymax`: `FLOAT64` maximum value for Y.
62+
63+
**Return type**
64+
65+
`GEOGRAPHY`
66+
67+
**Example**
68+
69+
``` sql
70+
SELECT bqcarto.constructors.ST_MAKEENVELOPE(0,0,1,1);
71+
-- POLYGON((1 0, 1 1, 0 1, 0 0, 1 0))
72+
```
73+
74+
### ST_TILEENVELOPE
75+
76+
{{% bannerNote type="code" %}}
77+
constructors.ST_TILEENVELOPE(zoomLevel, xTile, yTile)
78+
{{%/ bannerNote %}}
79+
80+
**Description**
81+
Returns the boundary polygon of a tile given its zoom level and its X and Y indices.
82+
83+
* `zoomLevel`: `INT64` zoom level of the tile.
84+
* `xTile`: `INT64` X index of the tile.
85+
* `yTile`: `INT64` Y index of the tile.
86+
87+
**Return type**
88+
89+
`GEOGRAPHY`
90+
91+
**Example**
92+
93+
``` sql
94+
SELECT bqcarto.constructors.ST_TILEENVELOPE(10,384,368);
95+
-- POLYGON((-45 45.089035564831, -45 44.840290651398, -44.82421875 44.840290651398, -44.6484375 44.840290651398, -44.6484375 45.089035564831, -44.82421875 45.089035564831, -45 45.089035564831))
96+
```
97+
98+
### VERSION
99+
100+
{{% bannerNote type="code" %}}
101+
constructors.VERSION()
102+
{{%/ bannerNote %}}
103+
104+
**Description**
105+
106+
Returns the current version of the constructors module.
107+
108+
**Return type**
109+
110+
`STRING`
111+
112+
**Example**
113+
114+
```sql
115+
SELECT bqcarto.constructors.VERSION();
116+
-- 1.1.0
117+
```
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
## measurements
2+
3+
<div class="badge core"></div>
4+
5+
### ST_ANGLE
6+
7+
{{% bannerNote type="code" %}}
8+
measurements.ST_ANGLE(startPoint, midPoint, endPoint, mercator)
9+
{{%/ bannerNote %}}
10+
11+
**Description**
12+
13+
Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise) angle with origin on the startPoint-midPoint segment, or its explementary angle if required. https://github.com/Turfjs/turf/tree/master/packages/turf-angle
14+
15+
* `startPoint`: `GEOGRAPHY` start Point Coordinates.
16+
* `midPoint`: `GEOGRAPHY` mid Point Coordinates.
17+
* `endPoint`: `GEOGRAPHY` end Point Coordinates.
18+
* `mercator`: `BOOLEAN`|`NULL` if calculations should be performed over Mercator or WGS84 projection. If `NULL` the default value `false` is used.
19+
20+
**Return type**
21+
22+
`FLOAT64`
23+
24+
**Example**
25+
26+
``` sql
27+
SELECT bqcarto.measurements.ST_ANGLE(ST_GEOGPOINT(-3.70325 ,40.4167), ST_GEOGPOINT(-4.70325 ,10.4167), ST_GEOGPOINT(-5.70325 ,40.4167), false);
28+
-- 3.933094586038578
29+
```
30+
31+
### ST_AZIMUTH
32+
33+
{{% bannerNote type="code" %}}
34+
measurements.ST_AZIMUTH(startPoint, endPoint)
35+
{{%/ bannerNote %}}
36+
37+
**Description**
38+
39+
Takes two points and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees). https://turfjs.org/docs/#bearing
40+
41+
* `startPoint`: `GEOGRAPHY` starting Point.
42+
* `endPoint`: `GEOGRAPHY` ending Point.
43+
44+
**Return type**
45+
46+
`FLOAT64`
47+
48+
**Example**
49+
50+
``` sql
51+
SELECT bqcarto.measurements.ST_AZIMUTH(ST_GEOGPOINT(-3.70325 ,40.4167), ST_GEOGPOINT(-4.70325 ,41.4167));
52+
-- -36.75052908494255
53+
```
54+
55+
### ST_MINKOWSKIDISTANCE
56+
57+
{{% bannerNote type="code" %}}
58+
measurements.ST_MINKOWSKIDISTANCE(geog, p)
59+
{{%/ bannerNote %}}
60+
61+
**Description**
62+
63+
Calculate the Minkowski p-norm distance between two features. https://github.com/Turfjs/turf/tree/master/packages/turf-distance-weight
64+
65+
* `geog`: `ARRAY<GEOGRAPHY>` featureCollection.
66+
* `p`: `FLOAT64` minkowski p-norm distance parameter. 1: Manhattan distance. 2: Euclidean distance. 1 =< p <= infinity. If `NULL` the default value `2` is used.
67+
68+
**Return type**
69+
70+
`ARRAY<STRING>`
71+
72+
**Example**
73+
74+
``` sql
75+
SELECT bqcarto.measurements.ST_MINKOWSKIDISTANCE([ST_GEOGPOINT(10,10),ST_GEOGPOINT(13,10)],2);
76+
-- ["0,0.3333333333333333","0.3333333333333333,0"]
77+
```
78+
79+
80+
### VERSION
81+
82+
{{% bannerNote type="code" %}}
83+
measurements.VERSION()
84+
{{%/ bannerNote %}}
85+
86+
**Description**
87+
88+
Returns the current version of the measurements module.
89+
90+
**Return type**
91+
92+
`STRING`
93+
94+
**Example**
95+
96+
```sql
97+
SELECT bqcarto.measurements.VERSION();
98+
-- 1.0.0
99+
```

app/content/spatial-extension-bq/sql-reference/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The CARTO Spatial Extension's procedures and functions are organized in modules
1313
| Placekey | Core | <ul style="list-style:none"><li><a href="../placekey/#h3_asplacekey">H3_ASPLACEKEY</a></li><li><a href="../placekey/#placekey_ash3">PLACEKEY_ASH3</a></li><li><a href="../placekey/#isvalid">ISVALID</a></li><li><a href="../placekey/#version">VERSION</a></li></ul>|
1414
| Random | Advanced | <ul style="list-style:none"><li><a href="../random/#st_generatepoints">ST_GENERATEPOINTS</a></li></li><li><a href="../random/#version">VERSION</a></li></ul>|
1515
| Data | Advanced | <ul style="list-style:none"><li><a href="../data/#st_getpopulationdensity">ST_GETPOPULATIONDENSITY</a></li></li><li><a href="../data/#version">VERSION</a></li></ul>|
16-
| Transformation | Core | <ul style="list-style:none"><li><a href="../transformation/#st_buffer">ST_BUFFER</a></li></li><li><a href="../transformation/#version">VERSION</a></li></ul>|
16+
| Transformations | Core | <ul style="list-style:none"><li><a href="../transformations/#st_buffer">ST_BUFFER</a></li></li><li><a href="../transformations/#version">VERSION</a></li></ul>|
1717

1818
### Release notes
1919

app/content/spatial-extension-bq/sql-reference/transformation.md

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)