Socket
Socket
Sign inDemoInstall

turf-count

Package Overview
Dependencies
Maintainers
8
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-count

turf count module


Version published
Weekly downloads
103
decreased by-0.96%
Maintainers
8
Weekly downloads
 
Created
Source

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

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