turf-linetopolygondeprecated

A turf module to transform a LineString geometry to a (closed) Polygon geometry.

Usage no npm install needed!

<script type="module">
  import turfLinetopolygon from 'https://cdn.skypack.dev/turf-linetopolygon';
</script>

README

turf-lineToPolygon

Build Status

Transforms a LineString geometry to a (closed) Polygon geometry.

Usage

var lineToPolygon = require('turf-linetopolygon');

var lineFeature = {
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "LineString",
    "coordinates": [ [ 0,0 ], [ 0,1 ], [ 1,1 ], [ 1,0 ] ]
  }
};

var polyFeature = lineToPolygon(lineFeature);

Returns:

{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [ [ [ 0,0 ], [ 0,1 ], [ 1,1 ], [ 1,0 ], [ 0,0 ] ] ]
  }
}