geojson-split-crossing-lines

split collection of crossing lines

Usage no npm install needed!

<script type="module">
  import geojsonSplitCrossingLines from 'https://cdn.skypack.dev/geojson-split-crossing-lines';
</script>

README

geojson-split-crossing-lines

Turn a GeoJSON FeatureCollection of crossing lines into a clean network dataset.

npm install geojson-split-crossing-lines --save
const splitLines = require('geojson-split-crossing-lines');
const fs = require('fs').promises;

main();

async function main() {
    // load and parse GeoJSON LineString dataset
    const geo_raw = await fs.readFile('./whole.geojson', 'utf8');
    const geo = JSON.parse(geo_raw);

    const split = splitLines(geo);

    await fs.writeFile('./split.geojson', JSON.stringify(split), 'utf8');
}

For more information, please see my blog post; Cleaning a GeoJSON Network.