Converts a WKT geometry string to a GeoJSON geometry object.
Supports all 7 standardised WKT geometry types (2D and 3D/Z): Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, GeometryCollection.
Point
LineString
Polygon
MultiPoint
MultiLineString
MultiPolygon
GeometryCollection
SRID=4326;POINT(...)
Z
M
ZM
null
WKT geometry string.
A GeoJSON geometry object, or null on failure.
wktToGeoJSON("POINT(2.3522 48.8566)")// → { type: "Point", coordinates: [2.3522, 48.8566] }wktToGeoJSON("POINT Z (2.3522 48.8566 35)")// → { type: "Point", coordinates: [2.3522, 48.8566, 35] } Copy
wktToGeoJSON("POINT(2.3522 48.8566)")// → { type: "Point", coordinates: [2.3522, 48.8566] }wktToGeoJSON("POINT Z (2.3522 48.8566 35)")// → { type: "Point", coordinates: [2.3522, 48.8566, 35] }
Converts a WKT geometry string to a GeoJSON geometry object.
Supports all 7 standardised WKT geometry types (2D and 3D/Z):
Point,LineString,Polygon,MultiPoint,MultiLineString,MultiPolygon,GeometryCollection.SRID=4326;POINT(...)) are stripped before parsing.Z,M,ZM) are accepted and ignored.nullwhen the input is null, empty, or syntactically invalid.