summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/functions-geometry.html
blob: 66e4b3569281a9a0aec80fa4592033a08f2aca28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>9.11. Geometric Functions and Operators</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="functions-enum.html" title="9.10. Enum Support Functions" /><link rel="next" href="functions-net.html" title="9.12. Network Address Functions and Operators" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">9.11. Geometric Functions and Operators</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="functions-enum.html" title="9.10. Enum Support Functions">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="functions.html" title="Chapter 9. Functions and Operators">Up</a></td><th width="60%" align="center">Chapter 9. Functions and Operators</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.7 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="functions-net.html" title="9.12. Network Address Functions and Operators">Next</a></td></tr></table><hr /></div><div class="sect1" id="FUNCTIONS-GEOMETRY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">9.11. Geometric Functions and Operators</h2></div></div></div><p>
    The geometric types <code class="type">point</code>, <code class="type">box</code>,
    <code class="type">lseg</code>, <code class="type">line</code>, <code class="type">path</code>,
    <code class="type">polygon</code>, and <code class="type">circle</code> have a large set of
    native support functions and operators, shown in <a class="xref" href="functions-geometry.html#FUNCTIONS-GEOMETRY-OP-TABLE" title="Table 9.36. Geometric Operators">Table 9.36</a>, <a class="xref" href="functions-geometry.html#FUNCTIONS-GEOMETRY-FUNC-TABLE" title="Table 9.37. Geometric Functions">Table 9.37</a>, and <a class="xref" href="functions-geometry.html#FUNCTIONS-GEOMETRY-CONV-TABLE" title="Table 9.38. Geometric Type Conversion Functions">Table 9.38</a>.
   </p><div class="table" id="FUNCTIONS-GEOMETRY-OP-TABLE"><p class="title"><strong>Table 9.36. Geometric Operators</strong></p><div class="table-contents"><table class="table" summary="Geometric Operators" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
        Operator
       </p>
       <p>
        Description
       </p>
       <p>
        Example(s)
       </p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">+</code> <code class="type">point</code><code class="returnvalue"><em class="replaceable"><code>geometric_type</code></em></code>
       </p>
       <p>
        Adds the coordinates of the second <code class="type">point</code> to those of each
        point of the first argument, thus performing translation.
        Available for <code class="type">point</code>, <code class="type">box</code>, <code class="type">path</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(1,1),(0,0)' + point '(2,0)'</code><code class="returnvalue">(3,1),(2,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">path</code> <code class="literal">+</code> <code class="type">path</code><code class="returnvalue">path</code>
       </p>
       <p>
        Concatenates two open paths (returns NULL if either path is closed).
       </p>
       <p>
        <code class="literal">path '[(0,0),(1,1)]' + path '[(2,2),(3,3),(4,4)]'</code><code class="returnvalue">[(0,0),(1,1),(2,2),(3,3),(4,4)]</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">-</code> <code class="type">point</code><code class="returnvalue"><em class="replaceable"><code>geometric_type</code></em></code>
       </p>
       <p>
        Subtracts the coordinates of the second <code class="type">point</code> from those
        of each point of the first argument, thus performing translation.
        Available for <code class="type">point</code>, <code class="type">box</code>, <code class="type">path</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(1,1),(0,0)' - point '(2,0)'</code><code class="returnvalue">(-1,1),(-2,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">*</code> <code class="type">point</code><code class="returnvalue"><em class="replaceable"><code>geometric_type</code></em></code>
       </p>
       <p>
        Multiplies each point of the first argument by the second
        <code class="type">point</code> (treating a point as being a complex number
        represented by real and imaginary parts, and performing standard
        complex multiplication).  If one interprets
        the second <code class="type">point</code> as a vector, this is equivalent to
        scaling the object's size and distance from the origin by the length
        of the vector, and rotating it counterclockwise around the origin by
        the vector's angle from the <em class="replaceable"><code>x</code></em> axis.
        Available for <code class="type">point</code>, <code class="type">box</code>,<a href="#ftn.FUNCTIONS-GEOMETRY-ROTATION-FN" class="footnote"><sup class="footnote" id="FUNCTIONS-GEOMETRY-ROTATION-FN">[a]</sup></a>
        <code class="type">path</code>, <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">path '((0,0),(1,0),(1,1))' * point '(3.0,0)'</code><code class="returnvalue">((0,0),(3,0),(3,3))</code>
       </p>
       <p>
        <code class="literal">path '((0,0),(1,0),(1,1))' * point(cosd(45), sind(45))</code><code class="returnvalue">((0,0),​(0.7071067811865475,0.7071067811865475),​(0,1.414213562373095))</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">/</code> <code class="type">point</code><code class="returnvalue"><em class="replaceable"><code>geometric_type</code></em></code>
       </p>
       <p>
        Divides each point of the first argument by the second
        <code class="type">point</code> (treating a point as being a complex number
        represented by real and imaginary parts, and performing standard
        complex division).  If one interprets
        the second <code class="type">point</code> as a vector, this is equivalent to
        scaling the object's size and distance from the origin down by the
        length of the vector, and rotating it clockwise around the origin by
        the vector's angle from the <em class="replaceable"><code>x</code></em> axis.
        Available for <code class="type">point</code>, <code class="type">box</code>,<a href="functions-geometry.html#ftn.FUNCTIONS-GEOMETRY-ROTATION-FN" class="footnoteref"><sup class="footnoteref">[a]</sup></a> <code class="type">path</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">path '((0,0),(1,0),(1,1))' / point '(2.0,0)'</code><code class="returnvalue">((0,0),(0.5,0),(0.5,0.5))</code>
       </p>
       <p>
        <code class="literal">path '((0,0),(1,0),(1,1))' / point(cosd(45), sind(45))</code><code class="returnvalue">((0,0),​(0.7071067811865476,-0.7071067811865476),​(1.4142135623730951,0))</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="literal">@-@</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes the total length.
        Available for <code class="type">lseg</code>, <code class="type">path</code>.
       </p>
       <p>
        <code class="literal">@-@ path '[(0,0),(1,0),(1,1)]'</code><code class="returnvalue">2</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="literal">@@</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">point</code>
       </p>
       <p>
        Computes the center point.
        Available for <code class="type">box</code>, <code class="type">lseg</code>,
        <code class="type">polygon</code>, <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">@@ box '(2,2),(0,0)'</code><code class="returnvalue">(1,1)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="literal">#</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">integer</code>
       </p>
       <p>
        Returns the number of points.
        Available for <code class="type">path</code>, <code class="type">polygon</code>.
       </p>
       <p>
        <code class="literal"># path '((1,0),(0,1),(-1,0))'</code><code class="returnvalue">3</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">#</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">point</code>
       </p>
       <p>
        Computes the point of intersection, or NULL if there is none.
        Available for <code class="type">lseg</code>, <code class="type">line</code>.
       </p>
       <p>
        <code class="literal">lseg '[(0,0),(1,1)]' # lseg '[(1,0),(0,1)]'</code><code class="returnvalue">(0.5,0.5)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">box</code> <code class="literal">#</code> <code class="type">box</code><code class="returnvalue">box</code>
       </p>
       <p>
        Computes the intersection of two boxes, or NULL if there is none.
       </p>
       <p>
        <code class="literal">box '(2,2),(-1,-1)' # box '(1,1),(-2,-2)'</code><code class="returnvalue">(1,1),(-1,-1)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">##</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">point</code>
       </p>
       <p>
        Computes the closest point to the first object on the second object.
        Available for these pairs of types:
        (<code class="type">point</code>, <code class="type">box</code>),
        (<code class="type">point</code>, <code class="type">lseg</code>),
        (<code class="type">point</code>, <code class="type">line</code>),
        (<code class="type">lseg</code>, <code class="type">box</code>),
        (<code class="type">lseg</code>, <code class="type">lseg</code>),
        (<code class="type">line</code>, <code class="type">lseg</code>).
       </p>
       <p>
        <code class="literal">point '(0,0)' ## lseg '[(2,0),(0,2)]'</code><code class="returnvalue">(1,1)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&lt;-&gt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes the distance between the objects.
        Available for all seven geometric types, for all combinations
        of <code class="type">point</code> with another geometric type, and for
        these additional pairs of types:
        (<code class="type">box</code>, <code class="type">lseg</code>),
        (<code class="type">lseg</code>, <code class="type">line</code>),
        (<code class="type">polygon</code>, <code class="type">circle</code>)
        (and the commutator cases).
       </p>
       <p>
        <code class="literal">circle '&lt;(0,0),1&gt;' &lt;-&gt; circle '&lt;(5,0),1&gt;'</code><code class="returnvalue">3</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">@&gt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Does first object contain second?
        Available for these pairs of types:
        (<code class="literal">box</code>, <code class="literal">point</code>),
        (<code class="literal">box</code>, <code class="literal">box</code>),
        (<code class="literal">path</code>, <code class="literal">point</code>),
        (<code class="literal">polygon</code>, <code class="literal">point</code>),
        (<code class="literal">polygon</code>, <code class="literal">polygon</code>),
        (<code class="literal">circle</code>, <code class="literal">point</code>),
        (<code class="literal">circle</code>, <code class="literal">circle</code>).
       </p>
       <p>
        <code class="literal">circle '&lt;(0,0),2&gt;' @&gt; point '(1,1)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&lt;@</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is first object contained in or on second?
        Available for these pairs of types:
        (<code class="literal">point</code>, <code class="literal">box</code>),
        (<code class="literal">point</code>, <code class="literal">lseg</code>),
        (<code class="literal">point</code>, <code class="literal">line</code>),
        (<code class="literal">point</code>, <code class="literal">path</code>),
        (<code class="literal">point</code>, <code class="literal">polygon</code>),
        (<code class="literal">point</code>, <code class="literal">circle</code>),
        (<code class="literal">box</code>, <code class="literal">box</code>),
        (<code class="literal">lseg</code>, <code class="literal">box</code>),
        (<code class="literal">lseg</code>, <code class="literal">line</code>),
        (<code class="literal">polygon</code>, <code class="literal">polygon</code>),
        (<code class="literal">circle</code>, <code class="literal">circle</code>).
       </p>
       <p>
        <code class="literal">point '(1,1)' &lt;@ circle '&lt;(0,0),2&gt;'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&amp;&amp;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Do these objects overlap?  (One point in common makes this true.)
        Available for <code class="type">box</code>, <code class="type">polygon</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(1,1),(0,0)' &amp;&amp; box '(2,2),(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&lt;&lt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is first object strictly left of second?
        Available for <code class="type">point</code>, <code class="type">box</code>,
        <code class="type">polygon</code>, <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">circle '&lt;(0,0),1&gt;' &lt;&lt; circle '&lt;(5,0),1&gt;'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&gt;&gt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is first object strictly right of second?
        Available for <code class="type">point</code>, <code class="type">box</code>,
        <code class="type">polygon</code>, <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">circle '&lt;(5,0),1&gt;' &gt;&gt; circle '&lt;(0,0),1&gt;'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&amp;&lt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Does first object not extend to the right of second?
        Available for <code class="type">box</code>, <code class="type">polygon</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(1,1),(0,0)' &amp;&lt; box '(2,2),(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&amp;&gt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Does first object not extend to the left of second?
        Available for <code class="type">box</code>, <code class="type">polygon</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(3,3),(0,0)' &amp;&gt; box '(2,2),(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&lt;&lt;|</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is first object strictly below second?
        Available for <code class="type">point</code>, <code class="type">box</code>, <code class="type">polygon</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(3,3),(0,0)' &lt;&lt;| box '(5,5),(3,4)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">|&gt;&gt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is first object strictly above second?
        Available for <code class="type">point</code>, <code class="type">box</code>, <code class="type">polygon</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(5,5),(3,4)' |&gt;&gt; box '(3,3),(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">&amp;&lt;|</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Does first object not extend above second?
        Available for <code class="type">box</code>, <code class="type">polygon</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(1,1),(0,0)' &amp;&lt;| box '(2,2),(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">|&amp;&gt;</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Does first object not extend below second?
        Available for <code class="type">box</code>, <code class="type">polygon</code>,
        <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">box '(3,3),(0,0)' |&amp;&gt; box '(2,2),(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">box</code> <code class="literal">&lt;^</code> <code class="type">box</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is first object below second (allows edges to touch)?
       </p>
       <p>
        <code class="literal">box '((1,1),(0,0))' &lt;^ box '((2,2),(1,1))'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">box</code> <code class="literal">&gt;^</code> <code class="type">box</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is first object above second (allows edges to touch)?
       </p>
       <p>
        <code class="literal">box '((2,2),(1,1))' &gt;^ box '((1,1),(0,0))'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">?#</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Do these objects intersect?
        Available for these pairs of types:
        (<code class="type">box</code>, <code class="type">box</code>),
        (<code class="type">lseg</code>, <code class="type">box</code>),
        (<code class="type">lseg</code>, <code class="type">lseg</code>),
        (<code class="type">lseg</code>, <code class="type">line</code>),
        (<code class="type">line</code>, <code class="type">box</code>),
        (<code class="type">line</code>, <code class="type">line</code>),
        (<code class="type">path</code>, <code class="type">path</code>).
       </p>
       <p>
        <code class="literal">lseg '[(-1,0),(1,0)]' ?# box '(2,2),(-2,-2)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="literal">?-</code> <code class="type">line</code><code class="returnvalue">boolean</code>
       </p>
       <p class="func_signature">
        <code class="literal">?-</code> <code class="type">lseg</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is line horizontal?
       </p>
       <p>
        <code class="literal">?- lseg '[(-1,0),(1,0)]'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">point</code> <code class="literal">?-</code> <code class="type">point</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Are points horizontally aligned (that is, have same y coordinate)?
       </p>
       <p>
        <code class="literal">point '(1,0)' ?- point '(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="literal">?|</code> <code class="type">line</code><code class="returnvalue">boolean</code>
       </p>
       <p class="func_signature">
        <code class="literal">?|</code> <code class="type">lseg</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Is line vertical?
       </p>
       <p>
        <code class="literal">?| lseg '[(-1,0),(1,0)]'</code><code class="returnvalue">f</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">point</code> <code class="literal">?|</code> <code class="type">point</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Are points vertically aligned (that is, have same x coordinate)?
       </p>
       <p>
        <code class="literal">point '(0,1)' ?| point '(0,0)'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">line</code> <code class="literal">?-|</code> <code class="type">line</code><code class="returnvalue">boolean</code>
       </p>
       <p class="func_signature">
        <code class="type">lseg</code> <code class="literal">?-|</code> <code class="type">lseg</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Are lines perpendicular?
       </p>
       <p>
        <code class="literal">lseg '[(0,0),(0,1)]' ?-| lseg '[(0,0),(1,0)]'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="type">line</code> <code class="literal">?||</code> <code class="type">line</code><code class="returnvalue">boolean</code>
       </p>
       <p class="func_signature">
        <code class="type">lseg</code> <code class="literal">?||</code> <code class="type">lseg</code><code class="returnvalue">boolean</code>
       </p>
       <p>
        Are lines parallel?
       </p>
       <p>
        <code class="literal">lseg '[(-1,0),(1,0)]' ?|| lseg '[(-1,2),(1,2)]'</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <em class="replaceable"><code>geometric_type</code></em> <code class="literal">~=</code> <em class="replaceable"><code>geometric_type</code></em><code class="returnvalue">boolean</code>
       </p>
       <p>
        Are these objects the same?
        Available for <code class="type">point</code>, <code class="type">box</code>,
        <code class="type">polygon</code>, <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">polygon '((0,0),(1,1))' ~= polygon '((1,1),(0,0))'</code><code class="returnvalue">t</code>
       </p></td></tr></tbody><tbody class="footnotes"><tr><td colspan="1"><div id="ftn.FUNCTIONS-GEOMETRY-ROTATION-FN" class="footnote"><p><a href="#FUNCTIONS-GEOMETRY-ROTATION-FN" class="para"><sup class="para">[a] </sup></a><span class="quote"><span class="quote">Rotating</span></span> a
        box with these operators only moves its corner points: the box is
        still considered to have sides parallel to the axes.  Hence the box's
        size is not preserved, as a true rotation would do.</p></div></td></tr></tbody></table></div></div><br class="table-break" /><div class="caution"><h3 class="title">Caution</h3><p>
     Note that the <span class="quote"><span class="quote">same as</span></span> operator, <code class="literal">~=</code>,
     represents the usual notion of equality for the <code class="type">point</code>,
     <code class="type">box</code>, <code class="type">polygon</code>, and <code class="type">circle</code> types.
     Some of the geometric types also have an <code class="literal">=</code> operator, but
     <code class="literal">=</code> compares for equal <span class="emphasis"><em>areas</em></span> only.
     The other scalar comparison operators (<code class="literal">&lt;=</code> and so
     on), where available for these types, likewise compare areas.
    </p></div><div class="note"><h3 class="title">Note</h3><p>
     Before <span class="productname">PostgreSQL</span> 14, the point
     is strictly below/above comparison operators <code class="type">point</code>
     <code class="literal">&lt;&lt;|</code> <code class="type">point</code> and <code class="type">point</code>
     <code class="literal">|&gt;&gt;</code> <code class="type">point</code> were respectively
     called <code class="literal">&lt;^</code> and <code class="literal">&gt;^</code>.  These
     names are still available, but are deprecated and will eventually be
     removed.
    </p></div><div class="table" id="FUNCTIONS-GEOMETRY-FUNC-TABLE"><p class="title"><strong>Table 9.37. Geometric Functions</strong></p><div class="table-contents"><table class="table" summary="Geometric Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
        Function
       </p>
       <p>
        Description
       </p>
       <p>
        Example(s)
       </p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.1.1.1.1" class="indexterm"></a>
        <code class="function">area</code> ( <em class="replaceable"><code>geometric_type</code></em> )
        → <code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes area.
        Available for <code class="type">box</code>, <code class="type">path</code>, <code class="type">circle</code>.
        A <code class="type">path</code> input must be closed, else NULL is returned.
        Also, if the <code class="type">path</code> is self-intersecting, the result may be
        meaningless.
       </p>
       <p>
        <code class="literal">area(box '(2,2),(0,0)')</code><code class="returnvalue">4</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.2.1.1.1" class="indexterm"></a>
        <code class="function">center</code> ( <em class="replaceable"><code>geometric_type</code></em> )
        → <code class="returnvalue">point</code>
       </p>
       <p>
        Computes center point.
        Available for <code class="type">box</code>, <code class="type">circle</code>.
       </p>
       <p>
        <code class="literal">center(box '(1,2),(0,0)')</code><code class="returnvalue">(0.5,1)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.3.1.1.1" class="indexterm"></a>
        <code class="function">diagonal</code> ( <code class="type">box</code> )
        → <code class="returnvalue">lseg</code>
       </p>
       <p>
        Extracts box's diagonal as a line segment
        (same as <code class="function">lseg(box)</code>).
       </p>
       <p>
        <code class="literal">diagonal(box '(1,2),(0,0)')</code><code class="returnvalue">[(1,2),(0,0)]</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.4.1.1.1" class="indexterm"></a>
        <code class="function">diameter</code> ( <code class="type">circle</code> )
        → <code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes diameter of circle.
       </p>
       <p>
        <code class="literal">diameter(circle '&lt;(0,0),2&gt;')</code><code class="returnvalue">4</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.5.1.1.1" class="indexterm"></a>
        <code class="function">height</code> ( <code class="type">box</code> )
        → <code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes vertical size of box.
       </p>
       <p>
        <code class="literal">height(box '(1,2),(0,0)')</code><code class="returnvalue">2</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.6.1.1.1" class="indexterm"></a>
        <code class="function">isclosed</code> ( <code class="type">path</code> )
        → <code class="returnvalue">boolean</code>
       </p>
       <p>
        Is path closed?
       </p>
       <p>
        <code class="literal">isclosed(path '((0,0),(1,1),(2,0))')</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.7.1.1.1" class="indexterm"></a>
        <code class="function">isopen</code> ( <code class="type">path</code> )
        → <code class="returnvalue">boolean</code>
       </p>
       <p>
        Is path open?
       </p>
       <p>
        <code class="literal">isopen(path '[(0,0),(1,1),(2,0)]')</code><code class="returnvalue">t</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.8.1.1.1" class="indexterm"></a>
        <code class="function">length</code> ( <em class="replaceable"><code>geometric_type</code></em> )
        → <code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes the total length.
        Available for <code class="type">lseg</code>, <code class="type">path</code>.
       </p>
       <p>
        <code class="literal">length(path '((-1,0),(1,0))')</code><code class="returnvalue">4</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.9.1.1.1" class="indexterm"></a>
        <code class="function">npoints</code> ( <em class="replaceable"><code>geometric_type</code></em> )
        → <code class="returnvalue">integer</code>
       </p>
       <p>
        Returns the number of points.
        Available for <code class="type">path</code>, <code class="type">polygon</code>.
       </p>
       <p>
        <code class="literal">npoints(path '[(0,0),(1,1),(2,0)]')</code><code class="returnvalue">3</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.10.1.1.1" class="indexterm"></a>
        <code class="function">pclose</code> ( <code class="type">path</code> )
        → <code class="returnvalue">path</code>
       </p>
       <p>
        Converts path to closed form.
       </p>
       <p>
        <code class="literal">pclose(path '[(0,0),(1,1),(2,0)]')</code><code class="returnvalue">((0,0),(1,1),(2,0))</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.11.1.1.1" class="indexterm"></a>
        <code class="function">popen</code> ( <code class="type">path</code> )
        → <code class="returnvalue">path</code>
       </p>
       <p>
        Converts path to open form.
       </p>
       <p>
        <code class="literal">popen(path '((0,0),(1,1),(2,0))')</code><code class="returnvalue">[(0,0),(1,1),(2,0)]</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.12.1.1.1" class="indexterm"></a>
        <code class="function">radius</code> ( <code class="type">circle</code> )
        → <code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes radius of circle.
       </p>
       <p>
        <code class="literal">radius(circle '&lt;(0,0),2&gt;')</code><code class="returnvalue">2</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.13.1.1.1" class="indexterm"></a>
        <code class="function">slope</code> ( <code class="type">point</code>, <code class="type">point</code> )
        → <code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes slope of a line drawn through the two points.
       </p>
       <p>
        <code class="literal">slope(point '(0,0)', point '(2,1)')</code><code class="returnvalue">0.5</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.6.2.2.14.1.1.1" class="indexterm"></a>
        <code class="function">width</code> ( <code class="type">box</code> )
        → <code class="returnvalue">double precision</code>
       </p>
       <p>
        Computes horizontal size of box.
       </p>
       <p>
        <code class="literal">width(box '(1,2),(0,0)')</code><code class="returnvalue">1</code>
       </p></td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-GEOMETRY-CONV-TABLE"><p class="title"><strong>Table 9.38. Geometric Type Conversion Functions</strong></p><div class="table-contents"><table class="table" summary="Geometric Type Conversion Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
        Function
       </p>
       <p>
        Description
       </p>
       <p>
        Example(s)
       </p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.1.1.1.1" class="indexterm"></a>
        <code class="function">box</code> ( <code class="type">circle</code> )
        → <code class="returnvalue">box</code>
       </p>
       <p>
        Computes box inscribed within the circle.
       </p>
       <p>
        <code class="literal">box(circle '&lt;(0,0),2&gt;')</code><code class="returnvalue">(1.414213562373095,1.414213562373095),​(-1.414213562373095,-1.414213562373095)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">box</code> ( <code class="type">point</code> )
        → <code class="returnvalue">box</code>
       </p>
       <p>
        Converts point to empty box.
       </p>
       <p>
        <code class="literal">box(point '(1,0)')</code><code class="returnvalue">(1,0),(1,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">box</code> ( <code class="type">point</code>, <code class="type">point</code> )
        → <code class="returnvalue">box</code>
       </p>
       <p>
        Converts any two corner points to box.
       </p>
       <p>
        <code class="literal">box(point '(0,1)', point '(1,0)')</code><code class="returnvalue">(1,1),(0,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">box</code> ( <code class="type">polygon</code> )
        → <code class="returnvalue">box</code>
       </p>
       <p>
        Computes bounding box of polygon.
       </p>
       <p>
        <code class="literal">box(polygon '((0,0),(1,1),(2,0))')</code><code class="returnvalue">(2,1),(0,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.5.1.1.1" class="indexterm"></a>
        <code class="function">bound_box</code> ( <code class="type">box</code>, <code class="type">box</code> )
        → <code class="returnvalue">box</code>
       </p>
       <p>
        Computes bounding box of two boxes.
       </p>
       <p>
        <code class="literal">bound_box(box '(1,1),(0,0)', box '(4,4),(3,3)')</code><code class="returnvalue">(4,4),(0,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.6.1.1.1" class="indexterm"></a>
        <code class="function">circle</code> ( <code class="type">box</code> )
        → <code class="returnvalue">circle</code>
       </p>
       <p>
        Computes smallest circle enclosing box.
       </p>
       <p>
        <code class="literal">circle(box '(1,1),(0,0)')</code><code class="returnvalue">&lt;(0.5,0.5),0.7071067811865476&gt;</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">circle</code> ( <code class="type">point</code>, <code class="type">double precision</code> )
        → <code class="returnvalue">circle</code>
       </p>
       <p>
        Constructs circle from center and radius.
       </p>
       <p>
        <code class="literal">circle(point '(0,0)', 2.0)</code><code class="returnvalue">&lt;(0,0),2&gt;</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">circle</code> ( <code class="type">polygon</code> )
        → <code class="returnvalue">circle</code>
       </p>
       <p>
        Converts polygon to circle.  The circle's center is the mean of the
        positions of the polygon's points, and the radius is the average
        distance of the polygon's points from that center.
       </p>
       <p>
        <code class="literal">circle(polygon '((0,0),(1,3),(2,0))')</code><code class="returnvalue">&lt;(1,1),1.6094757082487299&gt;</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.9.1.1.1" class="indexterm"></a>
        <code class="function">line</code> ( <code class="type">point</code>, <code class="type">point</code> )
        → <code class="returnvalue">line</code>
       </p>
       <p>
        Converts two points to the line through them.
       </p>
       <p>
        <code class="literal">line(point '(-1,0)', point '(1,0)')</code><code class="returnvalue">{0,-1,0}</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.10.1.1.1" class="indexterm"></a>
        <code class="function">lseg</code> ( <code class="type">box</code> )
        → <code class="returnvalue">lseg</code>
       </p>
       <p>
        Extracts box's diagonal as a line segment.
       </p>
       <p>
        <code class="literal">lseg(box '(1,0),(-1,0)')</code><code class="returnvalue">[(1,0),(-1,0)]</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">lseg</code> ( <code class="type">point</code>, <code class="type">point</code> )
        → <code class="returnvalue">lseg</code>
       </p>
       <p>
        Constructs line segment from two endpoints.
       </p>
       <p>
        <code class="literal">lseg(point '(-1,0)', point '(1,0)')</code><code class="returnvalue">[(-1,0),(1,0)]</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.12.1.1.1" class="indexterm"></a>
        <code class="function">path</code> ( <code class="type">polygon</code> )
        → <code class="returnvalue">path</code>
       </p>
       <p>
        Converts polygon to a closed path with the same list of points.
       </p>
       <p>
        <code class="literal">path(polygon '((0,0),(1,1),(2,0))')</code><code class="returnvalue">((0,0),(1,1),(2,0))</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.13.1.1.1" class="indexterm"></a>
        <code class="function">point</code> ( <code class="type">double precision</code>, <code class="type">double precision</code> )
        → <code class="returnvalue">point</code>
       </p>
       <p>
        Constructs point from its coordinates.
       </p>
       <p>
        <code class="literal">point(23.4, -44.5)</code><code class="returnvalue">(23.4,-44.5)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">point</code> ( <code class="type">box</code> )
        → <code class="returnvalue">point</code>
       </p>
       <p>
        Computes center of box.
       </p>
       <p>
        <code class="literal">point(box '(1,0),(-1,0)')</code><code class="returnvalue">(0,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">point</code> ( <code class="type">circle</code> )
        → <code class="returnvalue">point</code>
       </p>
       <p>
        Computes center of circle.
       </p>
       <p>
        <code class="literal">point(circle '&lt;(0,0),2&gt;')</code><code class="returnvalue">(0,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">point</code> ( <code class="type">lseg</code> )
        → <code class="returnvalue">point</code>
       </p>
       <p>
        Computes center of line segment.
       </p>
       <p>
        <code class="literal">point(lseg '[(-1,0),(1,0)]')</code><code class="returnvalue">(0,0)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">point</code> ( <code class="type">polygon</code> )
        → <code class="returnvalue">point</code>
       </p>
       <p>
        Computes center of polygon (the mean of the
        positions of the polygon's points).
       </p>
       <p>
        <code class="literal">point(polygon '((0,0),(1,1),(2,0))')</code><code class="returnvalue">(1,0.3333333333333333)</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <a id="id-1.5.8.17.7.2.2.18.1.1.1" class="indexterm"></a>
        <code class="function">polygon</code> ( <code class="type">box</code> )
        → <code class="returnvalue">polygon</code>
       </p>
       <p>
        Converts box to a 4-point polygon.
       </p>
       <p>
        <code class="literal">polygon(box '(1,1),(0,0)')</code><code class="returnvalue">((0,0),(0,1),(1,1),(1,0))</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">polygon</code> ( <code class="type">circle</code> )
        → <code class="returnvalue">polygon</code>
       </p>
       <p>
        Converts circle to a 12-point polygon.
       </p>
       <p>
        <code class="literal">polygon(circle '&lt;(0,0),2&gt;')</code><code class="returnvalue">((-2,0),​(-1.7320508075688774,0.9999999999999999),​(-1.0000000000000002,1.7320508075688772),​(-1.2246063538223773e-16,2),​(0.9999999999999996,1.7320508075688774),​(1.732050807568877,1.0000000000000007),​(2,2.4492127076447545e-16),​(1.7320508075688776,-0.9999999999999994),​(1.0000000000000009,-1.7320508075688767),​(3.673819061467132e-16,-2),​(-0.9999999999999987,-1.732050807568878),​(-1.7320508075688767,-1.0000000000000009))</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">polygon</code> ( <code class="type">integer</code>, <code class="type">circle</code> )
        → <code class="returnvalue">polygon</code>
       </p>
       <p>
        Converts circle to an <em class="replaceable"><code>n</code></em>-point polygon.
       </p>
       <p>
        <code class="literal">polygon(4, circle '&lt;(3,0),1&gt;')</code><code class="returnvalue">((2,0),​(3,1),​(4,1.2246063538223773e-16),​(3,-1))</code>
       </p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
        <code class="function">polygon</code> ( <code class="type">path</code> )
        → <code class="returnvalue">polygon</code>
       </p>
       <p>
        Converts closed path to a polygon with the same list of points.
       </p>
       <p>
        <code class="literal">polygon(path '((0,0),(1,1),(2,0))')</code><code class="returnvalue">((0,0),(1,1),(2,0))</code>
       </p></td></tr></tbody></table></div></div><br class="table-break" /><p>
     It is possible to access the two component numbers of a <code class="type">point</code>
     as though the point were an array with indexes 0 and 1.  For example, if
     <code class="literal">t.p</code> is a <code class="type">point</code> column then
     <code class="literal">SELECT p[0] FROM t</code> retrieves the X coordinate and
     <code class="literal">UPDATE t SET p[1] = ...</code> changes the Y coordinate.
     In the same way, a value of type <code class="type">box</code> or <code class="type">lseg</code> can be treated
     as an array of two <code class="type">point</code> values.
    </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="functions-enum.html" title="9.10. Enum Support Functions">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="functions.html" title="Chapter 9. Functions and Operators">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="functions-net.html" title="9.12. Network Address Functions and Operators">Next</a></td></tr><tr><td width="40%" align="left" valign="top">9.10. Enum Support Functions </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.7 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 9.12. Network Address Functions and Operators</td></tr></table></div></body></html>