OGC Standard Geometry
LINESTRING
WKT LINESTRING: Linear Geometry Format & Syntax
Direct Definition:A WKT LINESTRING represents a continuous path composed of 1 or more connected linear segments defined by at least 2 coordinate points (e.g. roads, flight paths, pipeline routes, or GPS traces).
Valid Syntax & Example
LINESTRING (-77.0428 -12.0464, -77.0328 -12.0400, -77.0200 -12.0300, -77.0100 -12.0250)
Syntax: LINESTRING (x1 y1, x2 y2, x3 y3, ...)
Common Mistakes to Avoid
⚠️ Gotcha:
Supplying only 1 coordinate pair. A LINESTRING requires at least 2 distinct points (start and end).
PostGIS SQL Query Recipes
Creating and querying LINESTRING geometries in PostgreSQL:
1. Construct LINESTRING from WKT
SELECT ST_GeomFromText('LINESTRING (-77.04 -12.04, -77.03 -12.03, -77.02 -12.01)', 4326);2. Export LINESTRING to WKT text
SELECT ST_AsText(geom), ST_Length(geom::geography) AS length_meters FROM routes;
Python & Shapely Parsing
from shapely import wkt
line = wkt.loads("LINESTRING (0 0, 1 1, 2 0)")
print("Length:", line.length)Frequently Asked Questions
How do I calculate the length of a WKT LINESTRING in meters in PostGIS?+
Cast the geometry to geography: ST_Length(geom::geography). This computes geodesic distance along the earth curvature in meters.
Convert LINESTRING to Another Format
Every converter below accepts LINESTRING and runs entirely in your browser.
All GIS format converters →