Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Reduce coordinate density in KML files

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 node_modules
Octocat-spinner-32 README.md
Octocat-spinner-32 node-kml-reduce-density.js
README.md

KML Coordinate Density Reducer

by Ben Buckman, New Leaf Digital

Purpose

Given a KML file with more coordinates than necessary, this node script will reduce the coordinates to a requested density.

Written to create maps of my bike routes in Buenos Aires.

Note: This does not actually parse any XML, it simply regex's each line to find coordinates, strips out unwanted ones, and leaves the rest of the lines intact. The algorithm is very "dumb": given a reduce parameter of 2, it keeps every other (1 out of 2) coordinates; with 5, it strips 4/5; etc.

Usage

node ./node-kml-reduce-density.js --in [PATH] --out [PATH] --reduce [NUM]

Options:
  --in      source KML file                                                   [required]
  --out     write to new KML file                                             [required]
  --reduce  Preserve 1/N coordinates. 1=all, 4=25%, 10=10%. Default 2 (50%).  [required]  [default: 2]

Adaptations

Something went wrong with that request. Please try again.