# stream-geo-statistics

> streaming geo-statistics about GeoJSON

Latest version **0.0.2** (published 2014-04-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install stream-geo-statistics
pnpm add stream-geo-statistics
yarn add stream-geo-statistics
bun add stream-geo-statistics
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2014-04-17 |
| First published | 2014-04-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ryan Clark |
| Maintainers | rclark |

## Links

- npm: https://www.npmjs.com/package/stream-geo-statistics
- Repository: https://github.com/rclark/stream-geo-statistics
- Issues: https://github.com/rclark/stream-geo-statistics/issues
- npm.io page: https://npm.io/package/stream-geo-statistics

## Dependencies (5)

- [through2](https://npm.io/package/through2.md) ^0.4.1
- [spherical](https://npm.io/package/spherical.md) 0.0.1
- [underscore](https://npm.io/package/underscore.md) ^1.6.0
- [sphericalmercator](https://npm.io/package/sphericalmercator.md) ^1.0.2
- [stream-statistics](https://npm.io/package/stream-statistics.md) ^0.4.0

## Recent versions

- 0.0.2 (latest) — 2014-04-17
- 0.0.1 — 2014-04-17

## README

# stream-geo-statistics

A way to calculate geographic statistics about a set of GeoJSON features. This module presents you with a transparent pass-through stream that calculates statistics as you pass objects into it. This allows the module to fit in a processing or transformation pipeline and calculate statistics without getting in the way.

## Example

```javascript
var geoStatistics = require('stream-geo-statistics');
var geojsonStream = require('geojson-stream');
var myPipeline = require('./the-rest-of-my-pipeline');
var fs = require('fs');

fs.createReadStream('my-feature-collection.geojson')
    .pipe(geojsonStream.parse()) // Processes file as discrete features
    .pipe(geoStatistics())       // Collects statistics and passes features through
    .pipe(myPipeline);           // Receives features and does whatever to them

myPipeline.on('finish', function() {
    var stats = geoStatistics.getStats();    
});
```
## Usage

- You must stream in discrete GeoJSON features, not a stringified representation of a FeatureCollection. [geojson-stream](https://github.com/tmcw/geojson-stream) can help.

- Calling `.getStats()` will return an object with the following keys:
    - `bbox`: as and array of `[ east, south, west, north ]` for all features
    - `density`: as statistics on the distance between coordinates for all features
    - `duplicates`: as statistics on the number of duplicate coordinates per feature
    - `coordinates`: as statistics on the number of coordinates per feature
    - `features`: the number of features that have come through
    - `tiles`: spherical-mercator tiles as an array of `[ "z/x/y" ]` covering all features

- Each "statistics" object (e.g. `coordinates`) is data collected from a [stream-statistics](https://github.com/tmcw/stream-statistics) object that presents min, max, sum, mean, mode, variance, standard_deviation, geometric_mean and harmonic_mean.

## Options

Calculating tile lists is currently the most expensive operation by far. So, if you do not specifically ask for it, tile lists are not generated. In order to generate tile lists, you must pass an `options` object when creating your statistics stream. For example:

```javascript
var geoStatistics = require('stream-geo-statistics');
var myStream = geoStatistics({
    maxZoom: 14,    // must be provided in order to generate tile lists
    tileSize: 512   // optional, defaults to 256
});
```

---
_Source: https://npm.io/package/stream-geo-statistics · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
