1.0.1 • Published 9 years ago

geojson-tidy v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

Build Status

geojson-tidy

Create a tidy geojson by resmapling points in the feature based on sampling time and distance. Handy when geometries that have been converted from a noisy GPS/GPX output.

  • Set a minimum sampling time between successive points (Default: 5 seconds)
  • Set a minimum distance between successive points (Default: 10 metres)
  • Set a maximum feature length to split long segments (Default: 100 points)

untitled

install

npm install geojson-tidy

usage

var geojsonTidy = require('geojson-tidy');

var tidyLineString = geojsonTidy.geometry(obj, [options]);

###input Any geojson file from togeojson is a valid input for geojson-tidy. Only LineString features are processed currently.

The timestamp array for the trackpoints need to be stored stored in features[].properties.coordTimes[]. Both Unix time or Strings in ISO 8601 are accepted.

###output The default output is a geojson FeatureCollection with the timestamps stored in the ccordTimes[] property. All other properties are stripped out.

{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "coordTimes": []
            },
            "geometry": {
                "type": "LineString",
                "coordinates": []
            }
        }
    ]
}

To use with the Mapbox matchstick, you would want to generate only a single feature by using the {"output":"Feature"} option

API

geojsonTidy.geometry(obj, [options])

Given a geojson object, return contains a tidy geometry with extra points filtered out based on default settings

options

Allows you to set custom values for the filter

{
    minimumDistance: 10, // Minimum distance between points in metres
    minimumTime: 5,      // Minimum time interval between points in seconds
    maximumPoints: 100   // Maximum points in a feature
}

CLI

./geojson-tidy -h
Usage: geojson-tidy [-d minimum distance between points] [-t minimum sample time between points] [-m maximum number of points in a single line feature] FILE
FILE is any valid geojson file generated by togeojson
geojson-tidy returns a stingified gejosn FeatureCollection
Example: ./geojson-tidy test/walk-1.json -d 10 -t 5 -m 100 > output.json

Algorithm

  1. Read a geojson FeatureCollection
  2. Loop through the features for LineString features
  3. Compare successive coordinates of the feature
  4. If the dinstance between the points or timestamp difference is too small, delete it
  5. Write a tidied geojson FeatureCollection with reduced points
1.0.1

9 years ago

1.0.0

9 years ago

0.1.6

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago