Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.

caioiglesias/turf-flatten

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

turf-flatten

build status

Turf flatten module

turf.flatten(input)

flattens any GeoJSON to a FeatureCollection using geojson-flatten.

Parameters

parameter type description
input geojson any valid GeoJSON with multi-geometry Features

Example

var geometry = { 
  "type": "MultiPolygon",
  "coordinates": [
    [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
     [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
     [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
   ]
 };

var flattened = turf.flatten(geometry);

Returns a flattened FeatureCollection

{
  "type": "FeatureCollection",
  "features": [{
      "type": "Polygon",
      "coordinates": [
          [
              [102, 2],
              [103, 2],
              [103, 3],
              [102, 3],
              [102, 2]
          ]
      ]
  }, {
      "type": "Polygon",
      "coordinates": [
          [
              [100, 0],
              [101, 0],
              [101, 1],
              [100, 1],
              [100, 0]
          ],
          [
              [100.2, 0.2],
              [100.8, 0.2],
              [100.8, 0.8],
              [100.2, 0.8],
              [100.2, 0.2]
          ]
      ]
  }]
}

Installation

Requires nodejs.

$ npm install turf-flatten

Tests

$ npm test

About

Turf flatten module

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%