# turf-collect

> turf aggregate module

Latest version **3.0.12** (published 2016-07-05) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install turf-collect
pnpm add turf-collect
yarn add turf-collect
bun add turf-collect
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.0.12 |
| Published | 2016-07-05 |
| First published | 2016-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | morganherlocker |
| Maintainers | tmcw |
| Keywords | turf, aggregate, points, geojson, polygons, stats |

## Links

- npm: https://www.npmjs.com/package/turf-collect
- Repository: https://github.com/Turfjs/turf-aggregate
- Issues: https://github.com/Turfjs/turf-aggregate/issues
- npm.io page: https://npm.io/package/turf-collect

## Dependencies (1)

- [turf-inside](https://npm.io/package/turf-inside.md) ^3.0.12

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 3.0.12 (latest) — 2016-07-05
- 3.0.7-canary.ae89c8b3 (canary) — 2016-06-14
- 3.0.10 — 2016-06-15
- 3.0.7 — 2016-06-13
- 3.0.5 — 2016-05-17
- 3.0.3 — 2016-05-17

## README

# turf-collect

# collect

Joins attributes FeatureCollection of polygons with a FeatureCollection of
points. Given an `inProperty` on points and an `outProperty` for polygons,
this finds every point that lies within each polygon, collects the `inProperty`
values from those points, and adds them as an array to `outProperty` on the
polygon.

**Parameters**

-   `polygons` **FeatureCollection&lt;Polygon>** polygons with values on which to aggregate
-   `points` **FeatureCollection&lt;Point>** points to be aggregated
-   `inProperty` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** property to be nested from
-   `outProperty` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** property to be nested into

**Examples**

```javascript
var poly1 = polygon([[[0,0],[10,0],[10,10],[0,10],[0,0]]]);
var poly2 = polygon([[[10,0],[20,10],[20,20],[20,0],[10,0]]]);
var polyFC = featurecollection([poly1, poly2]);
var pt1 = point([5,5], {population: 200});
var pt2 = point([1,3], {population: 600});
var pt3 = point([14,2], {population: 100});
var pt4 = point([13,1], {population: 200});
var pt5 = point([19,7], {population: 300});
var ptFC = featurecollection([pt1, pt2, pt3, pt4, pt5]);
var aggregated = aggregate(polyFC, ptFC, 'population', 'values');

aggregated.features[0].properties.values // => [200, 600]);
```

Returns **FeatureCollection&lt;Polygon>** polygons with properties listed based on `outField`

---

This module is part of the [Turfjs project](http://turfjs.org/), an open source
module collection dedicated to geographic algorithms. It is maintained in the
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
PRs and issues.

### Installation

Install this module individually:

```sh
$ npm install turf-collect
```

Or install the Turf module that includes it as a function:

```sh
$ npm install turf
```

---
_Source: https://npm.io/package/turf-collect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
