geojson-network-node-snap
v1.0.2
Published
Snap line ends to nearest network node
Downloads
6
Readme
geojson-network-node-snap
Snap line ends to nearest network node
npm install geojson-network-node-snap --save
const snapNearby = require('geojson-network-node-snap');
const fs = require('fs').promises;
main();
async function main() {
// load and parse GeoJSON LineString dataset
const geo_raw = await fs.readFile('./rough_network.geojson', 'utf8');
const geo = JSON.parse(geo_raw);
// max km distance to look for a node to snap to
const km = 0.05;
// perform operation
const newGeo = snapNearby(geo, km);
// save new geojson to file
await fs.writeFile('./corrected_network.geojson', JSON.stringify(newGeo), 'utf8');
See blog post Cleaning a GeoJSON Network for more information.