# wkt

> Parse WKT (Well-known text) into geoJSON or stringify geoJSON into WKT

Latest version **0.1.1** (published 2019-11-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install wkt
pnpm add wkt
yarn add wkt
bun add wkt
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-11-01 |
| First published | 2019-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 21 |
| Author | Benjamin Reiersølmoen |
| Maintainers | benjrei |
| Keywords | WKT, GeoJSON, parse, stringify, convert, wellknown |

## Links

- npm: https://www.npmjs.com/package/wkt
- Repository: https://github.com/benrei/wkt
- Homepage: https://github.com/benrei/wkt#readme
- Issues: https://github.com/benrei/wkt/issues
- npm.io page: https://npm.io/package/wkt

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.1 (latest) — 2019-11-01
- 0.1.0 — 2019-10-31

## README

# wkt
[![NPM version](https://img.shields.io/npm/v/wkt.svg)](https://www.npmjs.com/package/wkt)

- Parse WKT ([Well-known text](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry)) 
into GeoJSON
- Stringify [GeoJSON](https://geojson.org/) into WKT

## Install

    npm install wkt

## Usage

### Parse
```js
const wkt = require('wkt');
const { parse } = require('wkt');

//  See return values in output section
wkt.parse('POINT(1 2)');
parse("POINT Z (58.51466818909509 8.629797415591964 61.77237)");
parse("LINESTRING (30 10, 10 30, 40 40)");
parse("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))");
```
#### Output from `parse()`
```
{ type: 'Point', coordinates: [ 1, 2 ] }
{ type: 'Point', coordinates: [ 58.51466818909509, 8.629797415591964, 61.77237 ] }
{ type: 'LineString', coordinates: [ [ 30, 10 ], [ 10, 30 ], [ 40, 40 ] ] }
{ type: 'Polygon', coordinates: [[[30,10], [40,40], [20,40], [10,20], [30,10]]] }
```
### Stringify
```javascript
const { stringify } = require('wkt');

const geometry = {
  type: "Point",
  coordinates: [125.6, 10.1, 54.2]
};
const geometry2 = { 
  type: 'LineString',
  coordinates: [ [ 30, 10 ], [ 10, 30 ], [ 40, 40 ] ] 
};

//  See return values in output section
stringify(geometry);
stringify(geometry2);
```
#### Output from `stringify()`
```
"POINT Z (125.6 10.1 54.2)"
"LINESTRING (30 10, 10 30, 40 40)"
```

## Docs

### `parse(wkt)`
Parse [Well-known text](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) string into GeoJSON

### `stringify(geojson)`

Stringifies a [GeoJSON](https://geojson.org/) `geometry` object or Feature object into a WKT (Well-known text) string.
Throws an error if given a `FeatureCollection` or unknown input.

### Supported types
* Point + MultiPoint
* LineString + MultiLineString
* Polygon + MultiPolygon
* GeometryCollection
* WKT's containing "Z"

---
_Source: https://npm.io/package/wkt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
