DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK

# 8.7. Geometric Types

Geometric data types represent two-dimensional spatial objects. Table 8-16 shows the geometric types available in PostgreSQL. The most fundamental type, the point, forms the basis for all of the other types.

Table 8-16. Geometric Types

NameStorage SizeRepresentationDescription
point16 bytesPoint on the plane(x,y)
line32 bytesInfinite line (not fully implemented)((x1,y1),(x2,y2))
lseg32 bytesFinite line segment((x1,y1),(x2,y2))
box32 bytesRectangular box((x1,y1),(x2,y2))
path16+16n bytesClosed path (similar to polygon)((x1,y1),...)
path16+16n bytesOpen path[(x1,y1),...]
polygon40+16n bytesPolygon (similar to closed path)((x1,y1),...)

A rich set of functions and operators is available to perform various geometric operations such as scaling, translation, rotation, and determining intersections. They are explained in Section 9.10.

## 8.7.1. Points

Points are the fundamental two-dimensional building block for geometric types. Values of type point are specified using the following syntax:

```( x , y )
x , y```

where x and y are the respective coordinates as floating-point numbers.

## 8.7.2. Line Segments

Line segments (lseg) are represented by pairs of points. Values of type lseg are specified using the following syntax:

```( ( x1 , y1 ) , ( x2 , y2 ) )
( x1 , y1 ) , ( x2 , y2 )
x1 , y1   ,   x2 , y2```

where (x1,y1) and (x2,y2) are the end points of the line segment.

## 8.7.3. Boxes

Boxes are represented by pairs of points that are opposite corners of the box. Values of type box are specified using the following syntax:

```( ( x1 , y1 ) , ( x2 , y2 ) )
( x1 , y1 ) , ( x2 , y2 )
x1 , y1   ,   x2 , y2```

where (x1,y1) and (x2,y2) are any two opposite corners of the box.

Boxes are output using the first syntax. The corners are reordered on input to store the upper right corner, then the lower left corner. Other corners of the box can be entered, but the lower left and upper right corners are determined from the input and stored.

## 8.7.4. Paths

Paths are represented by lists of connected points. Paths can be open, where the first and last points in the list are not considered connected, or closed, where the first and last points are considered connected.

Values of type path are specified using the following syntax:

```( ( x1 , y1 ) , ... , ( xn , yn ) )
[ ( x1 , y1 ) , ... , ( xn , yn ) ]
( x1 , y1 ) , ... , ( xn , yn )
( x1 , y1   , ... ,   xn , yn )
x1 , y1   , ... ,   xn , yn    ```

where the points are the end points of the line segments comprising the path. Square brackets ([]) indicate an open path, while parentheses (()) indicate a closed path.

Paths are output using the first syntax.

## 8.7.5. Polygons

Polygons are represented by lists of points (the vertexes of the polygon). Polygons should probably be considered equivalent to closed paths, but are stored differently and have their own set of support routines.

Values of type polygon are specified using the following syntax:

```( ( x1 , y1 ) , ... , ( xn , yn ) )
( x1 , y1 ) , ... , ( xn , yn )
( x1 , y1   , ... ,   xn , yn )
x1 , y1   , ... ,   xn , yn    ```

where the points are the end points of the line segments comprising the boundary of the polygon.

Polygons are output using the first syntax.

## 8.7.6. Circles

Circles are represented by a center point and a radius. Values of type circle are specified using the following syntax:

```< ( x , y ) , r >
( ( x , y ) , r )
( x , y ) , r
x , y   , r  ```

where (x,y) is the center and r is the radius of the circle.

Circles are output using the first syntax.
{"ft_lang_label":"__label__en","ft_lang_prob":0.718292,"math_prob":0.99378514,"size":3549,"snap":"2020-24-2020-29","text_gpt3_token_len":959,"char_repetition_ratio":0.14866008,"word_repetition_ratio":0.35182482,"special_character_ratio":0.32206255,"punctuation_ratio":0.22841966,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.996063,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-07-10T09:25:25Z\",\"WARC-Record-ID\":\"<urn:uuid:4def8bfa-df9b-4abf-818f-8c3618dbba2f>\",\"Content-Length\":\"14906\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:7b5326c1-a2e4-43db-94e0-1ef6f1229bd3>\",\"WARC-Concurrent-To\":\"<urn:uuid:6318930b-5c94-47b9-9983-06c91affd363>\",\"WARC-IP-Address\":\"132.147.224.138\",\"WARC-Target-URI\":\"http://osr5doc.xinuos.com/en/PostgresqlDoc/datatype-geometric.html\",\"WARC-Payload-Digest\":\"sha1:DN5PL4MP4H3MWNAKPPJQNSYETYF3CCI5\",\"WARC-Block-Digest\":\"sha1:OPJNP4OKMS6U3VA53WVAVQMAQMXANSUA\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-29/CC-MAIN-2020-29_segments_1593655906934.51_warc_CC-MAIN-20200710082212-20200710112212-00482.warc.gz\"}"}