OGC Standard Geometry

POLYGON

WKT POLYGON: Format, Syntax & PostGIS Guide

Direct Definition:A WKT POLYGON represents a planar surface defined by 1 exterior linear boundary ring and 0 or more interior boundary rings (islands or holes). The first and last coordinate of every ring must match identically to close the polygon.

Valid Syntax & Example

POLYGON ((-77.0428 -12.0464, -77.0328 -12.0464, -77.0328 -12.0364, -77.0428 -12.0364, -77.0428 -12.0464))
Syntax: POLYGON ((x1 y1, x2 y2, x3 y3, ..., x1 y1), (hole_x1 hole_y1, ...))

Common Mistakes to Avoid

⚠️ Gotcha:

Failing to repeat the starting coordinate at the end of the ring. A valid polygon with N vertices must have at least N+1 coordinate pairs in WKT.

✗ Invalid

POLYGON ((-77.0428 -12.0464, -77.0328 -12.0464, -77.0328 -12.0364, -77.0428 -12.0364)) -- Error: Ring does not close

✓ Valid

POLYGON ((-77.0428 -12.0464, -77.0328 -12.0464, -77.0328 -12.0364, -77.0428 -12.0364, -77.0428 -12.0464))

PostGIS SQL Query Recipes

Creating and querying POLYGON geometries in PostgreSQL:

1. Construct POLYGON from WKT

SELECT ST_GeomFromText('POLYGON ((-77.04 -12.04, -77.03 -12.04, -77.03 -12.03, -77.04 -12.03, -77.04 -12.04))', 4326);

2. Export POLYGON to WKT text

SELECT ST_AsText(geom) FROM parcels WHERE ST_GeometryType(geom) = 'ST_Polygon';

Python & Shapely Parsing

from shapely import wkt
polygon = wkt.loads("POLYGON ((-77.04 -12.04, -77.03 -12.04, -77.03 -12.03, -77.04 -12.03, -77.04 -12.04))")
print("Area:", polygon.area, "Bounds:", polygon.bounds)

Frequently Asked Questions

How are interior holes defined in a WKT POLYGON?+

Interior rings are specified as additional coordinate lists separated by commas inside the outer parentheses: POLYGON ((exterior_ring), (interior_hole_1), (interior_hole_2)).

What direction should vertices follow?+

Per OGC and GeoJSON RFC 7946 specifications, exterior rings should follow a counter-clockwise winding order and interior holes should follow clockwise order, though many database parsers accept both.

Convert POLYGON to Another Format

Every converter below accepts POLYGON and runs entirely in your browser.

All GIS format converters →

Other WKT Geometry Types