blob: 03fd823f956a1279e233a8223a9e02a716b7d942 [file] [log] [blame]
Ian Maxonbf8620b2024-04-01 16:09:18 -07001<!DOCTYPE html>
2<!--
3 | Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/markdown/geo/functions.md at 2024-04-01
4 | Rendered using Apache Maven Fluido Skin 1.7
5-->
6<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7 <head>
8 <meta charset="UTF-8" />
9 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10 <meta name="Date-Revision-yyyymmdd" content="20240401" />
11 <meta http-equiv="Content-Language" content="en" />
12 <title>AsterixDB &#x2013; Support the standard GIS objects (DRAFT)</title>
13 <link rel="stylesheet" href="../css/apache-maven-fluido-1.7.min.css" />
14 <link rel="stylesheet" href="../css/site.css" />
15 <link rel="stylesheet" href="../css/print.css" media="print" />
16 <script type="text/javascript" src="../js/apache-maven-fluido-1.7.min.js"></script>
17
18 </head>
19 <body class="topBarDisabled">
20 <div class="container-fluid">
21 <div id="banner">
22 <div class="pull-left"><a href=".././" id="bannerLeft"><img src="../images/asterixlogo.png" alt="AsterixDB"/></a></div>
23 <div class="pull-right"></div>
24 <div class="clear"><hr/></div>
25 </div>
26
27 <div id="breadcrumbs">
28 <ul class="breadcrumb">
29 <li id="publishDate">Last Published: 2024-04-01</li>
30 <li id="projectVersion" class="pull-right">Version: 0.9.9</li>
31 <li class="pull-right"><a href="../index.html" title="Documentation Home">Documentation Home</a></li>
32 </ul>
33 </div>
34 <div class="row-fluid">
35 <div id="leftColumn" class="span2">
36 <div class="well sidebar-nav">
37 <ul class="nav nav-list">
38 <li class="nav-header">Get Started - Installation</li>
39 <li><a href="../ncservice.html" title="Option 1: using NCService"><span class="none"></span>Option 1: using NCService</a></li>
40 <li><a href="../ansible.html" title="Option 2: using Ansible"><span class="none"></span>Option 2: using Ansible</a></li>
41 <li><a href="../aws.html" title="Option 3: using Amazon Web Services"><span class="none"></span>Option 3: using Amazon Web Services</a></li>
42 <li class="nav-header">AsterixDB Primer</li>
43 <li><a href="../sqlpp/primer-sqlpp.html" title="Using SQL++"><span class="none"></span>Using SQL++</a></li>
44 <li class="nav-header">Data Model</li>
45 <li><a href="../datamodel.html" title="The Asterix Data Model"><span class="none"></span>The Asterix Data Model</a></li>
46 <li class="nav-header">Queries</li>
47 <li><a href="../sqlpp/manual.html" title="The SQL++ Query Language"><span class="none"></span>The SQL++ Query Language</a></li>
48 <li><a href="../SQLPP.html" title="Raw SQL++ Grammar"><span class="none"></span>Raw SQL++ Grammar</a></li>
49 <li><a href="../sqlpp/builtins.html" title="Builtin Functions"><span class="none"></span>Builtin Functions</a></li>
50 <li class="nav-header">API/SDK</li>
51 <li><a href="../api.html" title="HTTP API"><span class="none"></span>HTTP API</a></li>
52 <li><a href="../csv.html" title="CSV Output"><span class="none"></span>CSV Output</a></li>
53 <li class="nav-header">Advanced Features</li>
54 <li><a href="../aql/externaldata.html" title="Accessing External Data"><span class="none"></span>Accessing External Data</a></li>
55 <li><a href="../feeds.html" title="Data Ingestion with Feeds"><span class="none"></span>Data Ingestion with Feeds</a></li>
56 <li><a href="../udf.html" title="User Defined Functions"><span class="none"></span>User Defined Functions</a></li>
57 <li><a href="../sqlpp/filters.html" title="Filter-Based LSM Index Acceleration"><span class="none"></span>Filter-Based LSM Index Acceleration</a></li>
58 <li><a href="../sqlpp/fulltext.html" title="Support of Full-text Queries"><span class="none"></span>Support of Full-text Queries</a></li>
59 <li><a href="../sqlpp/similarity.html" title="Support of Similarity Queries"><span class="none"></span>Support of Similarity Queries</a></li>
60 <li><a href="../geo/quickstart.html" title="GIS Support Overview"><span class="none"></span>GIS Support Overview</a></li>
61 <li class="active"><a href="#"><span class="none"></span>GIS Functions</a></li>
62 <li><a href="../interval_join.html" title="Support of Interval Joins"><span class="none"></span>Support of Interval Joins</a></li>
63 <li><a href="../spatial_join.html" title="Support of Spatial Joins"><span class="none"></span>Support of Spatial Joins</a></li>
64 <li><a href="../sqlpp/arrayindex.html" title="Support of Array Indexes"><span class="none"></span>Support of Array Indexes</a></li>
65 <li class="nav-header">Deprecated</li>
66 <li><a href="../aql/primer.html" title="AsterixDB Primer: Using AQL"><span class="none"></span>AsterixDB Primer: Using AQL</a></li>
67 <li><a href="../aql/manual.html" title="Queries: The Asterix Query Language (AQL)"><span class="none"></span>Queries: The Asterix Query Language (AQL)</a></li>
68 <li><a href="../aql/builtins.html" title="Queries: Builtin Functions (AQL)"><span class="none"></span>Queries: Builtin Functions (AQL)</a></li>
69</ul>
70 <hr />
71 <div id="poweredBy">
72 <div class="clear"></div>
73 <div class="clear"></div>
74 <div class="clear"></div>
75 <div class="clear"></div>
76<a href=".././" title="AsterixDB" class="builtBy"><img class="builtBy" alt="AsterixDB" src="../images/asterixlogo.png" /></a>
77 </div>
78 </div>
79 </div>
80 <div id="bodyColumn" class="span10" >
81<!--
82 ! Licensed to the Apache Software Foundation (ASF) under one
83 ! or more contributor license agreements. See the NOTICE file
84 ! distributed with this work for additional information
85 ! regarding copyright ownership. The ASF licenses this file
86 ! to you under the Apache License, Version 2.0 (the
87 ! "License"); you may not use this file except in compliance
88 ! with the License. You may obtain a copy of the License at
89 !
90 ! http://www.apache.org/licenses/LICENSE-2.0
91 !
92 ! Unless required by applicable law or agreed to in writing,
93 ! software distributed under the License is distributed on an
94 ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
95 ! KIND, either express or implied. See the License for the
96 ! specific language governing permissions and limitations
97 ! under the License.
98 !-->
99<h1>Support the standard GIS objects (DRAFT)</h1>
100<div class="section">
101<h2><a name="Table_of_Contents"></a><a name="toc" id="toc">Table of Contents</a></h2>
102<ul>
103
104<li><a href="#Introduction">Introduction</a></li>
105<li><a href="#construction">Construction functions</a></li>
106<li><a href="#primitive">Primitive functions</a></li>
107<li><a href="#predicate">Spatial Predicate</a></li>
108<li><a href="#analysis">Spatial Analysis</a></li>
109<li><a href="#aggregate">Spatial Aggregates</a></li>
110</ul></div>
111<div class="section">
112<h2><a name="Introduction" id="Introduction">Introduction</a></h2>
113<p>To support standard GIS objects in AsterixDB, you need to use the <tt>geometry</tt> data type as follows.</p>
114
115<div>
116<div>
117<pre class="source">DROP dataverse GeoJSON if exists;
118CREATE dataverse GeoJSON;
119
120USE GeoJSON;
121
122CREATE TYPE GeometryType AS{
123 id : int,
124 myGeometry : geometry
125};
126
127CREATE DATASET Geometries (GeometryType) PRIMARY KEY id;
128</pre></div></div>
129
130<p>Please note that even though the <a class="externalLink" href="http://desktop.arcgis.com/en/arcmap/10.3/manage-data/using-sql-with-gdbs/what-is-an-srid.htm">SRID</a> input is supported for certain functions and is represented internally in the correct manner the serialized result (printed in the output) displays the SRID as 4326 always because of the limitations in Esri API.</p></div>
131<div class="section">
132<h2><a name="Construction_functions"></a><a name="construction" id="construction">Construction functions</a></h2>
133<p>The Geometry datatype can be created by the constructor functions.</p>
134<div class="section">
135<h3><a name="st_make_point"></a>st_make_point</h3>
136<ul>
137
138<li>
139
140<p>Creates a 2D,3DZ or 4D point geometry.</p>
141</li>
142<li>
143
144<p>Example:</p>
145</li>
146<li>Create a 2D point at coordinates (x,y) = (-71, 42)</li>
147<li>Command:
148
149<div>
150<div>
151<pre class="source">st_make_point(-71, 42);
152</pre></div></div>
153</li>
154<li>Result:
155
156<div>
157<div>
158<pre class="source">{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[-71,42],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
159</pre></div></div>
160</li>
161<li>Example:</li>
162<li>Create a 3D point at coordinates (x,y,z) = (1,2,1.59)</li>
163<li>Command:
164
165<div>
166<div>
167<pre class="source">st_make_point(1,2,1.59);
168</pre></div></div>
169</li>
170<li>Result:
171
172<div>
173<div>
174<pre class="source">{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[1,2,1.59],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
175</pre></div></div>
176</li>
177</ul></div>
178<div class="section">
179<h3><a name="st_geom_from_text"></a>st_geom_from_text</h3>
180<ul>
181
182<li>
183
184<p>Return a specified ST_Geometry value from Well-Known Text representation (WKT).</p>
185</li>
186<li>
187
188<p>Example:</p>
189</li>
190<li>Create a LineString geometry from the WKT format.</li>
191<li>Command:
192
193<div>
194<div>
195<pre class="source">st_geom_from_text(&quot;LINESTRING(1 2,3 4,5 6)&quot;);
196</pre></div></div>
197</li>
198<li>Result:
199
200<div>
201<div>
202<pre class="source">{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[1,2],[3,4],[5,6]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
203</pre></div></div>
204</li>
205<li>Example:</li>
206<li>Create a MultiLineString geometry from the WKT format.</li>
207<li>Command:
208
209<div>
210<div>
211<pre class="source">st_geom_from_text('MULTILINESTRING((1 2,3 4,5 6),(7 8,9 10))');
212</pre></div></div>
213</li>
214<li>Result:
215
216<div>
217<div>
218<pre class="source">{&quot;type&quot;:&quot;MultiLineString&quot;,&quot;coordinates&quot;:[[[1,2],[3,4],[5,6]],[[7,8],[9,10]]],&quot;crs&quot;:null}
219</pre></div></div>
220</li>
221</ul></div>
222<div class="section">
223<h3><a name="st_geom_from_wkb"></a>st_geom_from_wkb</h3>
224<ul>
225
226<li>
227
228<p>Creates a geometry instance from a Well-Known Binary geometry representation (WKB) and optional SRID.</p>
229</li>
230<li>
231
232<p>Example:</p>
233</li>
234<li>Command:
235
236<div>
237<div>
238<pre class="source">st_geom_from_wkb(hex(&quot;010100000000000000000000400000000000001440&quot;));
239</pre></div></div>
240</li>
241<li>Result:
242
243<div>
244<div>
245<pre class="source">{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[2,5],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
246</pre></div></div>
247</li>
248</ul></div>
249<div class="section">
250<h3><a name="st_geom_from_geojson"></a>st_geom_from_geojson</h3>
251<ul>
252
253<li>
254
255<p>Creates a geometry instance from its GeoJSON representation</p>
256</li>
257<li>
258
259<p>Example:</p>
260</li>
261<li>Command:
262
263<div>
264<div>
265<pre class="source">st_geom_from_geojson({&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[2,5],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}});
266</pre></div></div>
267</li>
268<li>
269
270<p>Result:</p>
271
272<div>
273<div>
274<pre class="source">{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[2,5],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
275</pre></div></div>
276</li>
277</ul></div>
278<div class="section">
279<h3><a name="st_make_envelope"></a>st_make_envelope</h3>
280<ul>
281
282<li>
283
284<p>Creates a rectangular Polygon formed from the given minimums and maximums. Input values must be in SRS specified by the SRID.</p>
285</li>
286<li>
287
288<p>Example:</p>
289</li>
290<li>Command:
291
292<div>
293<div>
294<pre class="source">st_make_envelope(10, 10, 11, 11, 4326);
295</pre></div></div>
296</li>
297<li>Result:
298
299<div>
300<div>
301<pre class="source">{&quot;type&quot;:&quot;Polygon&quot;,&quot;coordinates&quot;:[[[10,10],[11,10],[11,11],[10,11],[10,10]]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
302</pre></div></div>
303</li>
304</ul></div></div>
305<div class="section">
306<h2><a name="Primitive_functions"></a><a name="primitive" id="primitive">Primitive functions</a></h2>
307<p>There are primitive functions that take as input geometry/es and return a primitive type.</p>
308<div class="section">
309<h3><a name="st_area"></a>st_area</h3>
310<ul>
311
312<li>
313
314<p>Return the area of the surface if it is a Polygon or MultiPolygon. For geometry, a 2D Cartesian area is determined with units specified by the SRID. For geography, area is determined on a curved surface with units in square meters.</p>
315</li>
316<li>
317
318<p>Example:</p>
319</li>
320<li>Command:
321
322<div>
323<div>
324<pre class="source">st_area(st_geom_from_text('POLYGON((7 2,4 9,3 6,2.6 7,8 16))'));
325</pre></div></div>
326</li>
327<li>Result:
328
329<div>
330<div>
331<pre class="source">26.500000000000007
332</pre></div></div>
333</li>
334</ul></div>
335<div class="section">
336<h3><a name="st_coord_dim"></a>st_coord_dim</h3>
337<ul>
338
339<li>
340
341<p>Return the coordinate dimension of the Geometry value.</p>
342</li>
343<li>
344
345<p>Example:</p>
346</li>
347<li>Command:
348
349<div>
350<div>
351<pre class="source">st_coord_dim(st_make_point(1,2));
352</pre></div></div>
353</li>
354<li>Result:
355
356<div>
357<div>
358<pre class="source">2
359</pre></div></div>
360</li>
361</ul></div>
362<div class="section">
363<h3><a name="st_dimension"></a>st_dimension</h3>
364<ul>
365
366<li>
367
368<p>Return the inherent dimension of this Geometry object, which must be less than or equal to the coordinate dimension.</p>
369</li>
370<li>
371
372<p>Example:</p>
373</li>
374<li>Command:
375
376<div>
377<div>
378<pre class="source">st_dimension(st_geom_from_text('GEOMETRYCOLLECTION(LINESTRING(1 1,0 0),POINT(0 0))'));
379</pre></div></div>
380</li>
381<li>Result:
382
383<div>
384<div>
385<pre class="source">1
386</pre></div></div>
387</li>
388</ul></div>
389<div class="section">
390<h3><a name="geometry_type"></a>geometry_type</h3>
391<ul>
392
393<li>
394
395<p>Return the type of the geometry as a string. Eg: &#x2018;LINESTRING&#x2019;, &#x2018;POLYGON&#x2019;, &#x2018;MULTIPOINT&#x2019;, etc.</p>
396</li>
397<li>
398
399<p>Example:</p>
400</li>
401<li>Command:
402
403<div>
404<div>
405<pre class="source">geometry_type(st_geom_from_text('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
406</pre></div></div>
407</li>
408<li>Result:
409
410<div>
411<div>
412<pre class="source">&quot;LineString&quot;
413</pre></div></div>
414</li>
415</ul></div>
416<div class="section">
417<h3><a name="st_m"></a>st_m</h3>
418<ul>
419
420<li>
421
422<p>Return the M coordinate of the point, or NULL if not available. Input must be a point.</p>
423</li>
424<li>
425
426<p>Example:</p>
427</li>
428<li>Command:
429
430<div>
431<div>
432<pre class="source">st_m(st_make_point(1, 2, 3, 4));
433</pre></div></div>
434</li>
435<li>Result:
436
437<div>
438<div>
439<pre class="source">4.0
440</pre></div></div>
441</li>
442</ul></div>
443<div class="section">
444<h3><a name="st_n_points"></a>st_n_points</h3>
445<ul>
446
447<li>
448
449<p>Return the number of points (vertexes) in a geometry.</p>
450</li>
451<li>
452
453<p>Example:</p>
454</li>
455<li>Command:
456
457<div>
458<div>
459<pre class="source">st_n_points(st_geom_from_text('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
460</pre></div></div>
461</li>
462<li>Result:
463
464<div>
465<div>
466<pre class="source">4
467</pre></div></div>
468</li>
469</ul></div>
470<div class="section">
471<h3><a name="st_n_rings"></a>st_n_rings</h3>
472<ul>
473
474<li>
475
476<p>If the geometry is a polygon or multi-polygon return the number of rings.</p>
477</li>
478<li>
479
480<p>Example:</p>
481</li>
482<li>Command:
483
484<div>
485<div>
486<pre class="source">st_n_rings(st_geom_from_text('POLYGON((10.689 -25.092, 34.595 -20.170, 38.814 -35.639, 13.502 -39.155, 10.689 -25.092))'));
487</pre></div></div>
488</li>
489<li>Result:
490
491<div>
492<div>
493<pre class="source">1
494</pre></div></div>
495</li>
496</ul></div>
497<div class="section">
498<h3><a name="st_num_geometries"></a>st_num_geometries</h3>
499<ul>
500
501<li>
502
503<p>If geometry is a GEOMETRYCOLLECTION (or MULTI*) return the number of geometries, for single geometries will return 1, otherwise return NULL.</p>
504</li>
505<li>
506
507<p>Example:</p>
508</li>
509<li>Command:
510
511<div>
512<div>
513<pre class="source">st_num_geometries(st_geom_from_text('LINESTRING(77.29 29.07,77.42 29.26,77.27 29.31,77.29 29.07)'));
514</pre></div></div>
515</li>
516<li>Result:
517
518<div>
519<div>
520<pre class="source">1
521</pre></div></div>
522</li>
523<li>Example:</li>
524<li>Command:
525
526<div>
527<div>
528<pre class="source">st_num_geometries(st_geom_from_text('GEOMETRYCOLLECTION(MULTIPOINT(-2 3 , -2 2), LINESTRING(5 5 ,10 10), POLYGON((-7 4.2,-7.1 5,-7.1 4.3,-7 4.2)))'));
529</pre></div></div>
530</li>
531<li>Result:
532
533<div>
534<div>
535<pre class="source">3
536</pre></div></div>
537</li>
538</ul></div>
539<div class="section">
540<h3><a name="st_num_interiorRings"></a>st_num_interiorRings</h3>
541<ul>
542
543<li>
544
545<p>Return the number of interior rings of a polygon geometry.</p>
546</li>
547<li>
548
549<p>Example:</p>
550</li>
551</ul>
552<p><img src="../images/linestring.png" alt="Image of interiorRings" /> * Command:</p>
553
554<div>
555<div>
556<pre class="source"> st_num_interior_rings(st_geom_from_text(&quot;POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))&quot;));
557</pre></div></div>
558
559<ul>
560
561<li>Result:
562
563<div>
564<div>
565<pre class="source">1
566</pre></div></div>
567</li>
568</ul></div>
569<div class="section">
570<h3><a name="st_x"></a>st_x</h3>
571<ul>
572
573<li>
574
575<p>Return the X coordinate of the point, or NULL if not available. Input must be a point.</p>
576</li>
577<li>
578
579<p>Example:</p>
580</li>
581<li>Command:
582
583<div>
584<div>
585<pre class="source">st_x(st_make_point(1, 2, 3, 4));
586</pre></div></div>
587</li>
588<li>Result:
589
590<div>
591<div>
592<pre class="source">1.0
593</pre></div></div>
594</li>
595</ul></div>
596<div class="section">
597<h3><a name="st_y"></a>st_y</h3>
598<ul>
599
600<li>
601
602<p>Return the Y coordinate of the point, or NULL if not available. Input must be a point.</p>
603</li>
604<li>
605
606<p>Example:</p>
607</li>
608<li>Command:
609
610<div>
611<div>
612<pre class="source">st_y(st_make_point(1, 2, 3, 4));
613</pre></div></div>
614</li>
615<li>Result:
616
617<div>
618<div>
619<pre class="source">1.0
620</pre></div></div>
621</li>
622</ul></div>
623<div class="section">
624<h3><a name="st_x_max"></a>st_x_max</h3>
625<ul>
626
627<li>
628
629<p>Return X maximum of a bounding box 2d or 3d or a geometry.</p>
630</li>
631<li>
632
633<p>Example:</p>
634</li>
635<li>Command:
636
637<div>
638<div>
639<pre class="source">st_x_max(st_geom_from_text('POLYGON((10.689 -25.092, 34.595 -20.170, 38.814 -35.639, 13.502 -39.155, 10.689 -25.092))'));
640</pre></div></div>
641</li>
642<li>Result:
643
644<div>
645<div>
646<pre class="source">38.814
647</pre></div></div>
648</li>
649</ul></div>
650<div class="section">
651<h3><a name="st_x_min"></a>st_x_min</h3>
652<ul>
653
654<li>Return X minimum of a bounding box 2d or 3d or a geometry.</li>
655</ul></div>
656<div class="section">
657<h3><a name="st_y_max"></a>st_y_max</h3>
658<ul>
659
660<li>Return Y maximum of a bounding box 2d or 3d or a geometry.</li>
661</ul></div>
662<div class="section">
663<h3><a name="st_y_min"></a>st_y_min</h3>
664<ul>
665
666<li>Return Y minimum of a bounding box 2d or 3d or a geometry.</li>
667</ul></div>
668<div class="section">
669<h3><a name="st_z"></a>st_z</h3>
670<ul>
671
672<li>Return the Z coordinate of the point, or NULL if not available. Input must be a point.</li>
673</ul></div>
674<div class="section">
675<h3><a name="st_z_max"></a>st_z_max</h3>
676<ul>
677
678<li>Return Z maximum of a bounding box 2d or 3d or a geometry.</li>
679</ul></div>
680<div class="section">
681<h3><a name="st_z_min"></a>st_z_min</h3>
682<ul>
683
684<li>Return Z minimum of a bounding box 2d or 3d or a geometry.</li>
685</ul></div>
686<div class="section">
687<h3><a name="st_as_binary"></a>st_as_binary</h3>
688<ul>
689
690<li>
691
692<p>Return the Well-Known Binary (WKB) representation of the geometry/geography without SRID meta data.</p>
693</li>
694<li>
695
696<p>Example:</p>
697</li>
698<li>Command:
699
700<div>
701<div>
702<pre class="source">st_as_binary(st_geom_from_geojson({&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[2,5],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}));
703</pre></div></div>
704</li>
705<li>Result:
706
707<div>
708<div>
709<pre class="source">&quot;010100000000000000000000400000000000001440&quot;
710</pre></div></div>
711</li>
712</ul></div>
713<div class="section">
714<h3><a name="st_as_geojson"></a>st_as_geojson</h3>
715<ul>
716
717<li>
718
719<p>Return the geometry as a GeoJSON element.</p>
720</li>
721<li>
722
723<p>Example:</p>
724</li>
725<li>Command:
726
727<div>
728<div>
729<pre class="source">st_as_geojson(st_geom_from_text('POLYGON((10.689 -25.092, 34.595 -20.170, 38.814 -35.639, 13.502 -39.155, 10.689 -25.092))'));
730</pre></div></div>
731</li>
732<li>Result:
733
734<div>
735<div>
736<pre class="source">&quot;{\&quot;type\&quot;:\&quot;Polygon\&quot;,\&quot;coordinates\&quot;:[[[10.689,-25.092],[13.502,-39.155],[38.814,-35.639],[34.595,-20.17],[10.689,-25.092]]],\&quot;crs\&quot;:{\&quot;type\&quot;:\&quot;name\&quot;,\&quot;properties\&quot;:{\&quot;name\&quot;:\&quot;EPSG:4326\&quot;}}}&quot;
737</pre></div></div>
738</li>
739</ul></div>
740<div class="section">
741<h3><a name="st_distance"></a>st_distance</h3>
742<ul>
743
744<li>
745
746<p>For geometry type Return the 2D Cartesian distance between two geometries in projected units (based on spatial ref). For geography type defaults to return minimum geodesic distance between two geographies in meters.</p>
747</li>
748<li>
749
750<p>Example:</p>
751</li>
752<li>Command:
753
754<div>
755<div>
756<pre class="source">st_distance(st_geom_from_text('POINT(-72.1235 42.3521)'),st_geom_from_text('LINESTRING(-72.1260 42.45, -72.123 42.1546)'));
757</pre></div></div>
758</li>
759<li>Result:
760
761<div>
762<div>
763<pre class="source">0.0015056772638282166
764</pre></div></div>
765</li>
766</ul></div>
767<div class="section">
768<h3><a name="st_length"></a>st_length</h3>
769<ul>
770
771<li>
772
773<p>Return the 2D length of the geometry if it is a LineString or MultiLineString. geometry are in units of spatial reference and geography are in meters (default spheroid).</p>
774</li>
775<li>
776
777<p>Example:</p>
778</li>
779<li>Command:
780
781<div>
782<div>
783<pre class="source">st_length(st_geom_from_text('LINESTRING(-72.1260 42.45, -72.1240 42.45666, -72.123 42.1546)'));
784</pre></div></div>
785</li>
786<li>Result:
787
788<div>
789<div>
790<pre class="source">0.30901547439030225
791</pre></div></div>
792</li>
793</ul></div></div>
794<div class="section">
795<h2><a name="Spatial_Predicate"></a><a name="predicate" id="predicate">Spatial Predicate</a></h2>
796<p>Spatial predicate functions test for a relationship between two geometries and return a Boolean value (true/false).</p>
797<div class="section">
798<h3><a name="st_intersects"></a>st_intersects</h3>
799<ul>
800
801<li>
802
803<p>Return TRUE if the Geometries/Geography &#x201c;spatially intersect in 2D&#x201d;.</p>
804</li>
805<li>
806
807<p>Example:</p>
808</li>
809<li>Command:
810
811<div>
812<div>
813<pre class="source">st_intersects(st_geom_from_text('POINT(0 0)'), st_geom_from_text('LINESTRING ( 0 0, 0 2 )'));
814</pre></div></div>
815</li>
816<li>Result:
817
818<div>
819<div>
820<pre class="source">true
821</pre></div></div>
822</li>
823</ul></div>
824<div class="section">
825<h3><a name="st_isclosed"></a>st_isclosed</h3>
826<ul>
827
828<li>
829
830<p>Return TRUE if the LINESTRING&#x2019;s start and end points are coincident.</p>
831</li>
832<li>
833
834<p>Example:</p>
835</li>
836<li>Command:
837
838<div>
839<div>
840<pre class="source">st_is_closed(st_geom_from_text('LINESTRING(0 0, 0 1, 1 1, 0 0)'));
841</pre></div></div>
842</li>
843<li>Result:
844
845<div>
846<div>
847<pre class="source">true
848</pre></div></div>
849</li>
850</ul></div>
851<div class="section">
852<h3><a name="st_iscollection"></a>st_iscollection</h3>
853<ul>
854
855<li>
856
857<p>Return TRUE if the argument is a collection (MULTI*, GEOMETRYCOLLECTION, &#x2026;)</p>
858</li>
859<li>
860
861<p>Example:</p>
862</li>
863<li>Command:
864
865<div>
866<div>
867<pre class="source">st_is_collection(st_geom_from_text('MULTIPOINT EMPTY'));
868</pre></div></div>
869</li>
870<li>Result:
871
872<div>
873<div>
874<pre class="source">true
875</pre></div></div>
876</li>
877</ul></div>
878<div class="section">
879<h3><a name="st_is_empty"></a>st_is_empty</h3>
880<ul>
881
882<li>
883
884<p>Return true if this Geometry is an empty geometrycollection, polygon, point etc.</p>
885</li>
886<li>
887
888<p>Example:</p>
889</li>
890<li>Command:
891
892<div>
893<div>
894<pre class="source">st_is_empty(st_geom_from_text('POLYGON EMPTY'));
895</pre></div></div>
896</li>
897<li>Result:
898
899<div>
900<div>
901<pre class="source">true
902</pre></div></div>
903</li>
904</ul></div>
905<div class="section">
906<h3><a name="st_is_ring"></a>st_is_ring</h3>
907<ul>
908
909<li>
910
911<p>Return TRUE if this LINESTRING is both closed and simple.</p>
912</li>
913<li>
914
915<p>Example:</p>
916</li>
917<li>Command:
918
919<div>
920<div>
921<pre class="source">st_is_ring(st_geom_from_text('LINESTRING(0 0, 0 1, 1 1, 1 0, 0 0)'));
922</pre></div></div>
923</li>
924<li>Result:
925
926<div>
927<div>
928<pre class="source">true
929</pre></div></div>
930</li>
931</ul></div>
932<div class="section">
933<h3><a name="st_is_simple"></a>st_is_simple</h3>
934<ul>
935
936<li>
937
938<p>Return (TRUE) if this Geometry has no anomalous geometric points, such as self intersection or self tangency.</p>
939</li>
940<li>
941
942<p>Example:</p>
943</li>
944<li>Command:
945
946<div>
947<div>
948<pre class="source">st_is_simple(st_geom_from_text('LINESTRING(1 1,2 2,2 3.5,1 3,1 2,2 1)'));
949</pre></div></div>
950</li>
951<li>Result:
952
953<div>
954<div>
955<pre class="source">false
956</pre></div></div>
957</li>
958</ul></div>
959<div class="section">
960<h3><a name="st_contains"></a>st_contains</h3>
961<ul>
962
963<li>
964
965<p>Return true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.</p>
966</li>
967<li>
968
969<p>Example:</p>
970</li>
971<li>Command:
972
973<div>
974<div>
975<pre class="source">st_contains(st_geom_from_text('LINESTRING(1 1,-1 -1,2 3.5,1 3,1 2,2 1)'), st_make_point(-1, -1));
976</pre></div></div>
977</li>
978<li>Result:
979
980<div>
981<div>
982<pre class="source">true
983</pre></div></div>
984</li>
985</ul></div>
986<div class="section">
987<h3><a name="st_crosses"></a>st_crosses</h3>
988<ul>
989
990<li>
991
992<p>Return TRUE if the supplied geometries have some, but not all, interior points in common.</p>
993</li>
994<li>
995
996<p>Example:</p>
997</li>
998<li>Command:
999
1000<div>
1001<div>
1002<pre class="source">st_crosses(st_geom_from_text('LINESTRING(1 1,2 2,3 3,4 4, 5 5,6 6)'), st_geom_from_text('LINESTRING(0 2,1 2,2 2,3 2,4 2,5 2)'));
1003</pre></div></div>
1004</li>
1005<li>Result:
1006
1007<div>
1008<div>
1009<pre class="source">true
1010</pre></div></div>
1011</li>
1012</ul></div>
1013<div class="section">
1014<h3><a name="st_disjoint"></a>st_disjoint</h3>
1015<ul>
1016
1017<li>
1018
1019<p>Return TRUE if the Geometries do not &#x201c;spatially intersect&#x201d; - if they do not share any space together.</p>
1020</li>
1021<li>
1022
1023<p>Example:</p>
1024</li>
1025<li>Command:
1026
1027<div>
1028<div>
1029<pre class="source">st_disjoint(st_geom_from_text('LINESTRING(1 1,2 2,3 3,4 4, 5 5,6 6)'), st_geom_from_text('POINT(0 0)'));
1030</pre></div></div>
1031</li>
1032<li>Result:
1033
1034<div>
1035<div>
1036<pre class="source">true
1037</pre></div></div>
1038</li>
1039</ul></div>
1040<div class="section">
1041<h3><a name="st_equals"></a>st_equals</h3>
1042<ul>
1043
1044<li>
1045
1046<p>Return true if the given geometries represent the same geometry. Directionality is ignored.</p>
1047</li>
1048<li>
1049
1050<p>Example:</p>
1051</li>
1052<li>Command:
1053
1054<div>
1055<div>
1056<pre class="source">st_equals(st_geom_from_text('LINESTRING(0 0, 10 10)'), st_geom_from_text('LINESTRING(0 0, 5 5, 10 10)'));
1057</pre></div></div>
1058</li>
1059<li>Result:
1060
1061<div>
1062<div>
1063<pre class="source">true
1064</pre></div></div>
1065</li>
1066</ul></div>
1067<div class="section">
1068<h3><a name="st_overlaps"></a>st_overlaps</h3>
1069<ul>
1070
1071<li>
1072
1073<p>Return TRUE if the Geometries share space, are of the same dimension, but are not completely contained by each other.</p>
1074</li>
1075<li>
1076
1077<p>Example:</p>
1078</li>
1079<li>Command:
1080
1081<div>
1082<div>
1083<pre class="source">st_overlaps(st_geom_from_text('LINESTRING(1 1,2 2,3 3,4 4, 5 5,6 6)'), st_geom_from_text('LINESTRING(0 2,1 2,2 2,3 3,4 2,5 2)'));
1084</pre></div></div>
1085</li>
1086<li>Result:
1087
1088<div>
1089<div>
1090<pre class="source">true
1091</pre></div></div>
1092</li>
1093</ul></div>
1094<div class="section">
1095<h3><a name="st_relate"></a>st_relate</h3>
1096<ul>
1097
1098<li>
1099
1100<p>Return true if this Geometry is spatially related to anotherGeometry, by testing for intersections between the Interior, Boundary and Exterior of the two geometries as specified by the values in the intersectionMatrixPattern.</p>
1101</li>
1102<li>
1103
1104<p>Example:</p>
1105</li>
1106<li>Command:
1107
1108<div>
1109<div>
1110<pre class="source">st_relate(st_geom_from_text('LINESTRING(1 2, 3 4)'), st_geom_from_text('LINESTRING(5 6, 7 8)'), &quot;FF1FF0102&quot;);
1111</pre></div></div>
1112</li>
1113<li>Result:
1114
1115<div>
1116<div>
1117<pre class="source">true
1118</pre></div></div>
1119</li>
1120</ul></div>
1121<div class="section">
1122<h3><a name="st_touches"></a>st_touches</h3>
1123<ul>
1124
1125<li>
1126
1127<p>Return TRUE if the geometries have at least one point in common, but their interiors do not intersect.</p>
1128</li>
1129<li>
1130
1131<p>Example:</p>
1132</li>
1133<li>Command:
1134
1135<div>
1136<div>
1137<pre class="source">st_touches(st_geom_from_text('LINESTRING(0 0, 1 1, 0 2)'), st_geom_from_text('POINT(0 2)'));
1138</pre></div></div>
1139</li>
1140<li>Result:
1141
1142<div>
1143<div>
1144<pre class="source">true
1145</pre></div></div>
1146</li>
1147</ul></div>
1148<div class="section">
1149<h3><a name="st_within"></a>st_within</h3>
1150<ul>
1151
1152<li>Return true if the geometry A is completely inside geometry B.</li>
1153</ul></div></div>
1154<div class="section">
1155<h2><a name="Spatial_Analysis"></a><a name="analysis" id="analysis">Spatial Analysis</a></h2>
1156<p>Spatial analysis functions take as input one or more geometries and return a geometry as output.</p>
1157<div class="section">
1158<h3><a name="st_union"></a>st_union</h3>
1159<ul>
1160
1161<li>
1162
1163<p>Return a geometry that represents the point set union of the Geometries.</p>
1164</li>
1165<li>
1166
1167<p>Example:</p>
1168</li>
1169<li>Command:
1170
1171<div>
1172<div>
1173<pre class="source">st_union(st_geom_from_text('LINESTRING(0 0, 1 1, 0 2)'), st_geom_from_text('POINT(0 2)'));
1174</pre></div></div>
1175</li>
1176<li>Result:
1177
1178<div>
1179<div>
1180<pre class="source">{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[0,0],[1,1],[0,2]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1181</pre></div></div>
1182</li>
1183</ul></div>
1184<div class="section">
1185<h3><a name="st_boundary"></a>st_boundary</h3>
1186<ul>
1187
1188<li>
1189
1190<p>Return the closure of the combinatorial boundary of this Geometry.</p>
1191</li>
1192<li>
1193
1194<p>Example:</p>
1195</li>
1196<li>Command:
1197
1198<div>
1199<div>
1200<pre class="source">st_boundary(st_geom_from_text('POLYGON((1 1,0 0, -1 1, 1 1))'));
1201</pre></div></div>
1202</li>
1203<li>Result:
1204
1205<div>
1206<div>
1207<pre class="source">{&quot;type&quot;:&quot;MultiLineString&quot;,&quot;coordinates&quot;:[[[1,1],[-1,1],[0,0],[1,1]]],&quot;crs&quot;:null}
1208</pre></div></div>
1209</li>
1210</ul></div>
1211<div class="section">
1212<h3><a name="st_end_point"></a>st_end_point</h3>
1213<ul>
1214
1215<li>
1216
1217<p>Return the last point of a LINESTRING or CIRCULARLINESTRING geometry as a POINT.</p>
1218</li>
1219<li>
1220
1221<p>Example:</p>
1222</li>
1223<li>Command:
1224
1225<div>
1226<div>
1227<pre class="source">st_end_point(st_geom_from_text('LINESTRING(1 1, 2 2, 3 3)'));
1228</pre></div></div>
1229</li>
1230<li>Result:
1231
1232<div>
1233<div>
1234<pre class="source">{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[3,3],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1235</pre></div></div>
1236</li>
1237</ul></div>
1238<div class="section">
1239<h3><a name="st_envelope"></a>st_envelope</h3>
1240<ul>
1241
1242<li>
1243
1244<p>Return a geometry representing the double precision (float8) bounding box of the supplied geometry.</p>
1245</li>
1246<li>
1247
1248<p>Example:</p>
1249</li>
1250<li>Command:
1251
1252<div>
1253<div>
1254<pre class="source">st_envelope(st_geom_from_text('LINESTRING(1 1, 2 2, 3 3)'));
1255</pre></div></div>
1256</li>
1257<li>Result:
1258
1259<div>
1260<div>
1261<pre class="source">{&quot;type&quot;:&quot;Polygon&quot;,&quot;coordinates&quot;:[[[1,1],[3,1],[3,3],[1,3],[1,1]]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1262</pre></div></div>
1263</li>
1264</ul></div>
1265<div class="section">
1266<h3><a name="st_exterior_ring"></a>st_exterior_ring</h3>
1267<ul>
1268
1269<li>
1270
1271<p>Return a line string representing the exterior ring of the POLYGON geometry. Return NULL if the geometry is not a polygon. Will not work with MULTIPOLYGON.</p>
1272</li>
1273<li>
1274
1275<p>Example:</p>
1276</li>
1277<li>Command:
1278
1279<div>
1280<div>
1281<pre class="source">st_exterior_ring(st_geom_from_text(&quot;POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))&quot;));
1282</pre></div></div>
1283</li>
1284<li>Result:
1285
1286<div>
1287<div>
1288<pre class="source">{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[35,10],[45,45],[15,40],[10,20],[35,10]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1289</pre></div></div>
1290</li>
1291</ul></div>
1292<div class="section">
1293<h3><a name="st_geometry_n"></a>st_geometry_n</h3>
1294<ul>
1295
1296<li>
1297
1298<p>Return the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, (MULTI)POINT, (MULTI)LINESTRING, MULTICURVE or (MULTI)POLYGON, POLYHEDRALSURFACE. Otherwise, return NULL.</p>
1299</li>
1300<li>
1301
1302<p>Example:</p>
1303</li>
1304<li>Command:
1305
1306<div>
1307<div>
1308<pre class="source">st_geometry_n(st_geom_from_text('GEOMETRYCOLLECTION(MULTIPOINT(-2 3 , -2 2),LINESTRING(5 5 ,10 10),POLYGON((-7 4.2,-7.1 5,-7.1 4.3,-7 4.2)))'),2);
1309</pre></div></div>
1310</li>
1311<li>Result:
1312
1313<div>
1314<div>
1315<pre class="source">{&quot;type&quot;:&quot;Polygon&quot;,&quot;coordinates&quot;:[[[-7,4.2],[-7.1,5],[-7.1,4.3],[-7,4.2]]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1316</pre></div></div>
1317</li>
1318</ul></div>
1319<div class="section">
1320<h3><a name="st_interior_ring_n"></a>st_interior_ring_n</h3>
1321<ul>
1322
1323<li>
1324
1325<p>Return the Nth interior linestring ring of the polygon geometry. Return NULL if the geometry is not a polygon or the given N is out of range.</p>
1326</li>
1327<li>
1328
1329<p>Example:</p>
1330</li>
1331<li>Command:
1332
1333<div>
1334<div>
1335<pre class="source">st_interior_ring_n(st_geom_from_text(&quot;POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))&quot;), 0);
1336</pre></div></div>
1337</li>
1338<li>Result:
1339
1340<div>
1341<div>
1342<pre class="source">{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[20,30],[35,35],[30,20],[20,30]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1343</pre></div></div>
1344</li>
1345</ul></div>
1346<div class="section">
1347<h3><a name="st_point_n"></a>st_point_n</h3>
1348<ul>
1349
1350<li>
1351
1352<p>Return the Nth point in the first LineString or circular LineString in the geometry. Negative values are counted backwards from the end of the LineString. Return NULL if there is no linestring in the geometry.</p>
1353</li>
1354<li>
1355
1356<p>Example:</p>
1357</li>
1358<li>Command:
1359
1360<div>
1361<div>
1362<pre class="source">st_point_n(st_geom_from_text(&quot;LINESTRING(1 1, 2 2, 3 3)&quot;), 1);
1363</pre></div></div>
1364</li>
1365<li>Result:
1366
1367<div>
1368<div>
1369<pre class="source">{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[2,2],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1370</pre></div></div>
1371</li>
1372</ul></div>
1373<div class="section">
1374<h3><a name="st_start_point"></a>st_start_point</h3>
1375<ul>
1376
1377<li>
1378
1379<p>Return the first point of a LINESTRING geometry as a POINT.</p>
1380</li>
1381<li>
1382
1383<p>Example:</p>
1384</li>
1385<li>Command:
1386
1387<div>
1388<div>
1389<pre class="source">st_start_point(st_geom_from_text(&quot;LINESTRING(1 1, 2 2, 3 3)&quot;));
1390</pre></div></div>
1391</li>
1392<li>Result:
1393
1394<div>
1395<div>
1396<pre class="source">{&quot;type&quot;:&quot;Point&quot;,&quot;coordinates&quot;:[1,1],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1397</pre></div></div>
1398</li>
1399</ul></div>
1400<div class="section">
1401<h3><a name="st_difference"></a>st_difference</h3>
1402<ul>
1403
1404<li>
1405
1406<p>Return a geometry that represents that part of geometry A that does not intersect with geometry B.</p>
1407</li>
1408<li>
1409
1410<p>Example:</p>
1411</li>
1412<li>Command:
1413
1414<div>
1415<div>
1416<pre class="source">st_difference(st_geom_from_text(&quot;LINESTRING(1 1, 2 2, 3 3)&quot;), st_geom_from_text(&quot;POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))&quot;));
1417</pre></div></div>
1418</li>
1419<li>Result:
1420
1421<div>
1422<div>
1423<pre class="source">{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[1,1],[2,2],[3,3]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1424</pre></div></div>
1425</li>
1426</ul></div>
1427<div class="section">
1428<h3><a name="st_intersection"></a>st_intersection</h3>
1429<ul>
1430
1431<li>
1432
1433<p>Return a geometry that represents the shared portion of geomA and geomB.</p>
1434</li>
1435<li>
1436
1437<p>Example:</p>
1438</li>
1439<li>Command:
1440
1441<div>
1442<div>
1443<pre class="source">st_intersection(st_geom_from_text(&quot;LINESTRING(1 1,2 2,3 3,4 4, 5 5,6 6)&quot;), st_geom_from_text(&quot;LINESTRING(0 2,1 2,2 2,3 3,4 2,5 2)&quot;));
1444</pre></div></div>
1445</li>
1446<li>Result:
1447
1448<div>
1449<div>
1450<pre class="source">{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[2,2],[3,3]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1451</pre></div></div>
1452</li>
1453</ul></div>
1454<div class="section">
1455<h3><a name="st_sym_difference"></a>st_sym_difference</h3>
1456<ul>
1457
1458<li>
1459
1460<p>Return a geometry that represents the portions of A and B that do not intersect. It is called a symmetric difference because ST_SymDifference(A,B) = ST_SymDifference(B,A).</p>
1461</li>
1462<li>
1463
1464<p>Example:</p>
1465</li>
1466<li>Command:
1467
1468<div>
1469<div>
1470<pre class="source">st_sym_difference(st_geom_from_text(&quot;LINESTRING(1 1,2 2,3 3,4 4, 5 5,6 6)&quot;), st_geom_from_text(&quot;LINESTRING(0 2,1 2,2 2,3 3,4 2,5 2)&quot;));
1471</pre></div></div>
1472</li>
1473<li>Result:
1474
1475<div>
1476<div>
1477<pre class="source">{&quot;type&quot;:&quot;MultiLineString&quot;,&quot;coordinates&quot;:[[[0,2],[1,2],[2,2],[1,1]],[[5,2],[4,2],[3,3],[4,4],[5,5],[6,6]]],&quot;crs&quot;:null}
1478</pre></div></div>
1479</li>
1480</ul></div>
1481<div class="section">
1482<h3><a name="st_polygonize"></a>st_polygonize</h3>
1483<ul>
1484
1485<li>
1486
1487<p>Aggregate. Creates a GeometryCollection containing possible polygons formed from the constituent linework of a set of geometries.</p>
1488</li>
1489<li>
1490
1491<p>Example:</p>
1492</li>
1493<li>Command:
1494
1495<div>
1496<div>
1497<pre class="source">st_polygonize([st_geom_from_text(&quot;LINESTRING(1 1,2 2,3 3,4 4, 5 5,6 6)&quot;), st_geom_from_text(&quot;LINESTRING(0 2,1 2,2 2,3 3,4 2,5 2)&quot;)]);
1498</pre></div></div>
1499</li>
1500<li>Result:
1501
1502<div>
1503<div>
1504<pre class="source">{&quot;type&quot;:&quot;GeometryCollection&quot;,&quot;geometries&quot;:[{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]]},{&quot;type&quot;:&quot;LineString&quot;,&quot;coordinates&quot;:[[0,2],[1,2],[2,2],[3,3],[4,2],[5,2]]}],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1505</pre></div></div>
1506</li>
1507</ul></div></div>
1508<div class="section">
1509<h2><a name="Spatial_Aggregates"></a><a name="aggregate" id="aggregate">Spatial Aggregates</a></h2>
1510<p>spatial aggregate function which takes as input a set of geometries and return one geometry as the result.</p>
1511<div class="section">
1512<h3><a name="st_union"></a>st_union</h3>
1513<ul>
1514
1515<li>
1516
1517<p>Returns a geometry that represents the point set union of the Geometries.</p>
1518</li>
1519<li>
1520
1521<p>Example:</p>
1522</li>
1523<li>Command:
1524
1525<div>
1526<div>
1527<pre class="source">st_union((SELECT VALUE gbu FROM [st_make_point(1.0,1.0),st_make_point(1.0,2.0)] as gbu));
1528</pre></div></div>
1529</li>
1530<li>Result:
1531
1532<div>
1533<div>
1534<pre class="source">{&quot;type&quot;:&quot;MultiPoint&quot;,&quot;coordinates&quot;:[[1,1],[1,2]],&quot;crs&quot;:{&quot;type&quot;:&quot;name&quot;,&quot;properties&quot;:{&quot;name&quot;:&quot;EPSG:4326&quot;}}}
1535</pre></div></div>
1536</li>
1537</ul></div></div>
1538 </div>
1539 </div>
1540 </div>
1541 <hr/>
1542 <footer>
1543 <div class="container-fluid">
1544 <div class="row-fluid">
1545<div class="row-fluid">Apache AsterixDB, AsterixDB, Apache, the Apache
1546 feather logo, and the Apache AsterixDB project logo are either
1547 registered trademarks or trademarks of The Apache Software
1548 Foundation in the United States and other countries.
1549 All other marks mentioned may be trademarks or registered
1550 trademarks of their respective owners.
1551 </div>
1552 </div>
1553 </div>
1554 </footer>
1555 </body>
1556</html>