A polygon is a closed two-dimensional figure formed by connected straight line segments. In geospatial systems, polygons model planar areas such as buildings, parks, lakes, cities, states, and theme parks. section 10.1 section 10.3.3
Use polygons to represent boundaries and query the areas they enclose:
- Represent a polygon with three or more points; rectangles are polygons whose opposite sides are equal and parallel. section 10.1 section 10.1.1
- Store polygon boundaries in a PostGIS geometry column, where the SRID determines the units used by measurements such as area. section 10.3.3 section 10.5.2
- Inspect complexity with ST_NPoints, measure extent with ST_Area, and find contained regions with ST_Within. section 10.5.2
- Distinguish a polygon from a MultiPolygon, which represents a collection of non-overlapping and non-adjacent polygons. section 10.3.3
Measure a theme-park polygon
Query the Walt Disney World boundary, then convert its SRID-based area from square meters into square kilometers and acres. The result contains 473 points and reports approximately 96.08 square kilometers, or 23,741.93 acres.
Find polygons and objects inside them
Use ST_Within to find distinct theme parks inside the Walt Disney World boundary, excluding the boundary itself with ST_Equals. The same pattern finds attractions or point amenities inside a specific park.
Table 10.1 Postgres geometric data types
| Type name |
Description |
Input format |
|
|
A point on a 2D plane |
|
|
|
An infinite straight line in 2D space |
|
|
|
A finite line segment between two points |
|
|
|
A rectangle defined by two opposite corners |
|
|
|
An open or closed path defined as a sequence of connected points |
open path: closed path: |
|
|
A closed polygon with three or more points |
|
|
|
A circle with a center and a radius |
|
Use the geometric-type table to compare polygon input syntax with points, line segments, boxes, paths, and circles. section 10.1.1
