Socket
Socket
Sign inDemoInstall

turf-sum

Package Overview
Dependencies
Maintainers
8
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-sum

turf sum module


Version published
Weekly downloads
53
decreased by-24.29%
Maintainers
8
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 06 Feb 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc