Note that the“same as”operator,
~=, represents the usual notion of equality for the
circletypes. Some of these types also have an
=compares for equal_areas_only. The other scalar comparison operators (
<=and so on) likewise compare areas for these types.
Table 9.33. Geometric Operators
Point or box of intersection
Number of points in path or polygon
Length or circumference
Closest point to first operand on second operand
Overlaps? (One point in common makes this true.)
Is strictly left of?
Is strictly right of?
Does not extend to the right of?
Does not extend to the left of?
Is strictly below?
`box '((0,0),(3,3))' <<
Is strictly above?
>> box '((0,0),(3,3))'`
Does not extend above?
`box '((0,0),(1,1))' &<
Does not extend below?
&> box '((0,0),(2,2))'`
Is below (allows touching)?
Is above (allows touching)?
Are horizontally aligned?
Are vertically aligned?
`point '(0,1)' ?
`lseg '((0,0),(0,1))' ?-
`lseg '((-1,0),(1,0))' ?
Contained in or on?
BeforePostgreSQL8.2, the containment operators
<@were respectively called
@. These names are still available, but are deprecated and will eventually be removed.
Table 9.34. Geometric Functions
diameter of circle
vertical size of box
a closed path?
an open path?
number of points
number of points
convert path to closed
convert path to open
radius of circle
horizontal size of box
Table 9.35. Geometric Type Conversion Functions
circle to box
point to empty box
points to box
polygon to box
boxes to bounding box
box to circle
center and radius to circle
polygon to circle
points to line
box diagonal to line segment
points to line segment
polygon to path
center of box
center of circle
center of line segment
center of polygon
box to 4-point polygon
circle to 12-point polygon
path to polygon
It is possible to access the two component numbers of a
pointas though the point were an array with indexes 0 and 1. For example, if
SELECT p FROM tretrieves the X coordinate and
UPDATE t SET p = ...changes the Y coordinate. In the same way, a value of type
lsegcan be treated as an array of two
areafunction works for the types
areafunction only works on the
pathdata type if the points in the
pathare non-intersecting. For example, the
path'((0,0),(0,1),(2,1),(2,2),(1,2),(1,0),(0,0))'::PATHwill not work; however, the following visually identical
path'((0,0),(0,1),(1,1),(1,2),(2,2),(2,1),(1,1),(1,0),(0,0))'::PATHwill work. If the concept of an intersecting versus non-intersecting
pathis confusing, draw both of the above
paths side by side on a piece of graph paper.