1.0.1 • Published 9 years ago

turf-sum v1.0.1

Weekly downloads
1,440
License
MIT
Repository
github
Last release
9 years ago

turf-sum

build status

turf sum module

turf.sum(polygons, points, inField, outField)

Calculates the sum of a field for Point features within a set of Polygon features.

Parameters

parametertypedescription
polygonsFeatureCollectiona FeatureCollection of Polygon features
pointsFeatureCollectiona FeatureCollection of Point features
inFieldStringthe field in input data to analyze
outFieldStringthe field in which to store results

Example

var polygons = turf.featurecollection([
  turf.polygon([[
    [-87.990188, 43.026486],
    [-87.990188, 43.062115],
    [-87.913284, 43.062115],
    [-87.913284, 43.026486],
    [-87.990188, 43.026486]
  ]]),
  turf.polygon([[
    [-87.973709, 42.962452],
    [-87.973709, 43.014689],
    [-87.904014, 43.014689],
    [-87.904014, 42.962452],
    [-87.973709, 42.962452]
  ]])
]);
var points = turf.featurecollection([
  turf.point([-87.974052, 43.049321], {population: 200}),
  turf.point([-87.957229, 43.037277], {population: 600}),
  turf.point([-87.931137, 43.048568], {population: 100}),
  turf.point([-87.963409, 42.99611], {population: 200}),
  turf.point([-87.94178, 42.974762], {population: 300})
]);

var aggregated = turf.sum(
  polygons, points, 'population', 'sum');

var result = turf.featurecollection(
  points.features.concat(aggregated.features));

//=result

Installation

Requires nodejs.

$ npm install turf-sum

Tests

$ npm test
1.0.1

9 years ago

1.0.0

9 years ago

0.1.2

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago