geojson-wkt
WKT → GeoJSON (PostGIS)
Use this skill when your data includes geometries as WKT strings (e.g., "POINT(-87.6 41.8)", "LINESTRING(...)", "POLYGON(...)") and you want a GeoJSON FeatureCollection for map display.
This skill documents the canonical raw SQL pattern for building GeoJSON from WKT using PostGIS.
When to use
- You receive an array of objects like
{ id, wkt, ... } - You want GeoJSON directly from Postgres
- You want consistent property shaping and GeoJSON output
Input assumptions
- WKT is valid (or you’ll get PostGIS parse errors)
- The WKT may or may not include an SRID (this pattern assumes no SRID unless you add it)
- Output should be web-map friendly (commonly EPSG:4326)
Canonical SQL pattern
From JSON input (WKT field)
More from mmbmf1/geospatial-skills
geojson-postgis
Serialize PostGIS geometry rows into a GeoJSON FeatureCollection for map display (4326, Feature + properties).
21geojson-points
Convert JSON rows with latitude/longitude fields into a GeoJSON FeatureCollection using raw PostGIS SQL.
16postgis-distance
Compute numeric distances safely with ST_Distance (geometry vs geography units) and pair with ST_DWithin for performance.
9postgis-dwithin
Distance-based spatial filtering with ST_DWithin, using index-friendly and unit-safe patterns.
8postgis-nearest
Find nearest features efficiently using PostGIS KNN (<->) and distance ordering (with SRID/unit guidance).
7postgis-extract-xy
Extract longitude and latitude from PostGIS geometries using ST_X and ST_Y safely.
7