开发者社区> 镜像站> NPM> turf-count
turf-count
turf count module
Last updated 6 years ago by morganherlocker .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install turf-count 
SYNC missed versions from official npm registry.

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

parameter type description
polygons FeatureCollection a FeatureCollection of Polygon features
points FeatureCollection a FeatureCollection of Point features
countField String a 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

Current Tags

  • 1.0.2                                ...           latest (6 years ago)

8 Versions

  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.4                                ...           7 years ago
  • 0.0.3                                ...           7 years ago
  • 0.0.2                                ...           7 years ago
  • 0.0.1                                ...           7 years ago
Downloads
Today 0
This Week 8
This Month 8
Last Day 0
Last Week 0
Last Month 3
Dependencies (1)
Dev Dependencies (8)
Dependents (2)