Package Exports
- turf-count
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (turf-count) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
turf-count
Calculates the number of points that fall within a set of polygons.
Install
npm install turf-countAPI
count(polygonCollection, pointCollection, countProperty)
polygonCollectionshould be a FeatureCollection of PolygonspointCollectionshould be a FeatureCollection of PointscountPropertyis the property in the returned FeatureCollection that records the count of points in each polygon.
Example
var point = require('turf-point')
var polygon = require('turf-polygon')
var featurecollection = require('turf-featurecollection')
var poly1 = polygon([[[0,0],[10,0],[10,10], [0,10]]])
var poly2 = polygon([[[10,0],[20,10],[20,20], [20,0]]])
var polyFC = featurecollection([poly1, poly2])
var pt1 = point(5,5, {population: 200})
var pt2 = point(1,3, {population: 600})
var ptFC = featurecollection([pt1, pt2])
var counted = count(polyFC, ptFC, 'pt_count')
console.log(counted)