1.0.2 • Published 9 years ago

turf-count v1.0.2

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

turf-count

build status

turf count module

turf.count(polygons, points, countField)

Takes a FeatureCollection of Point features and a FeatureCollection of Polygon features and calculates the number of points that fall within the set of polygons.

Parameters

parametertypedescription
polygonsFeatureCollectiona FeatureCollection of Polygon features
pointsFeatureCollectiona FeatureCollection of Point features
countFieldStringa field to append to the attributes of the Polygon features representing Point counts

Example

var polygons = turf.featurecollection([
 turf.polygon([[
   [-112.072391,46.586591],
   [-112.072391,46.61761],
   [-112.028102,46.61761],
   [-112.028102,46.586591],
   [-112.072391,46.586591]
 ]]),
 turf.polygon([[
   [-112.023983,46.570426],
   [-112.023983,46.615016],
   [-111.966133,46.615016],
   [-111.966133,46.570426],
   [-112.023983,46.570426]
 ]])
]);
var points = turf.featurecollection([
 turf.point([-112.0372, 46.608058], {population: 200}),
 turf.point([-112.045955, 46.596264],
   {population: 600})
]);

var counted = turf.count(polygons, points, 'pt_count');

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

//=result

Installation

Requires nodejs.

$ npm install turf-count

Tests

$ npm test
1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.0

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago