# @turf/geojson-rbush

> GeoJSON implementation of RBush

Latest version **7.4.0** (published 2026-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install @turf/geojson-rbush
pnpm add @turf/geojson-rbush
yarn add @turf/geojson-rbush
bun add @turf/geojson-rbush
```

## Health

**Score 80/100 (A)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 7.4.0 |
| Published | 2026-08-03 |
| First published | 2021-10-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 52.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 10489 |
| Author | Turf Authors |
| Maintainers | rowanwins, tmcw, morganherlocker, tcql, mdfedderly, twelch, jamesmilneruk, morgan.herlocker |
| Keywords | geojson, index, tree, spatial, rbush |

## Links

- npm: https://www.npmjs.com/package/@turf/geojson-rbush
- Repository: https://github.com/Turfjs/turf
- Issues: https://github.com/Turfjs/turf/issues
- Funding: https://opencollective.com/turf
- npm.io page: https://npm.io/package/@turf/geojson-rbush

## Dependencies (6)

- [rbush](https://npm.io/package/rbush.md) ^3.0.1
- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [@turf/bbox](https://npm.io/package/@turf/bbox.md) 7.4.0
- [@turf/meta](https://npm.io/package/@turf/meta.md) 7.4.0
- [@turf/helpers](https://npm.io/package/@turf/helpers.md) 7.4.0
- [@types/geojson](https://npm.io/package/@types/geojson.md) ^7946.0.10

## 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

- 7.4.0 (latest) — 2026-08-03
- 7.1.0-alpha.70 (prerelease) — 2024-08-09
- 7.3.5 — 2026-04-19
- 7.3.4 — 2026-02-08
- 7.3.3 — 2026-01-28
- 7.3.2 — 2026-01-14
- 7.3.1 — 2025-11-27
- 7.3.0 — 2025-11-17
- 7.2.0 — 2024-12-29
- 7.1.0 — 2024-08-09
- 7.1.0-alpha.7 — 2024-06-25
- 7.0.0 — 2024-06-07
- 7.0.0-alpha.116 — 2024-05-07
- 7.0.0-alpha.115 — 2024-04-23
- 7.0.0-alpha.114 — 2024-03-11
- … 6 more at https://npm.io/package/@turf/geojson-rbush/versions

## README

# @turf/geojson-rbush

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## rbush

### insert

[insert][1]

#### Parameters

*   `feature` **[Feature][2]** insert single GeoJSON Feature

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);
tree.insert(poly)
```

Returns **RBush** GeoJSON RBush

### load

[load][3]

#### Parameters

*   `features` **([FeatureCollection][4] | [Array][5]<[Feature][2]>)** load entire GeoJSON FeatureCollection

#### Examples

```javascript
var polys = turf.polygons([
    [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]],
    [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]
]);
tree.load(polys);
```

Returns **RBush** GeoJSON RBush

### remove

[remove][6]

#### Parameters

*   `feature` **[Feature][2]** remove single GeoJSON Feature
*   `equals` **[Function][7]** Pass a custom equals function to compare by value for removal.

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);

tree.remove(poly);
```

Returns **RBush** GeoJSON RBush

### clear

[clear][6]

#### Examples

```javascript
tree.clear()
```

Returns **RBush** GeoJSON Rbush

### search

[search][8]

#### Parameters

*   `geojson` **([BBox][9] | [FeatureCollection][4] | [Feature][2])** search with GeoJSON

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);

tree.search(poly);
```

Returns **[FeatureCollection][4]** all features that intersects with the given GeoJSON.

### collides

[collides][10]

#### Parameters

*   `geojson` **([BBox][9] | [FeatureCollection][4] | [Feature][2])** collides with GeoJSON

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);

tree.collides(poly);
```

Returns **[boolean][11]** true if there are any items intersecting the given GeoJSON, otherwise false.

### all

[all][8]

#### Examples

```javascript
tree.all()
```

Returns **[FeatureCollection][4]** all the features in RBush

### toJSON

[toJSON][12]

#### Examples

```javascript
var exported = tree.toJSON()
```

Returns **any** export data as JSON object

### fromJSON

[fromJSON][12]

#### Parameters

*   `json` **any** import previously exported data

#### Examples

```javascript
var exported = {
  "children": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [110, 50]
      },
      "properties": {},
      "bbox": [110, 50, 110, 50]
    }
  ],
  "height": 1,
  "leaf": true,
  "minX": 110,
  "minY": 50,
  "maxX": 110,
  "maxY": 50
}
tree.fromJSON(exported)
```

Returns **RBush** GeoJSON RBush

## rbush

GeoJSON implementation of [RBush][13] spatial index.

### Parameters

*   `maxEntries` **[number][14]** defines the maximum number of entries in a tree node. 9 (used by default) is a
    reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa. (optional, default `9`)

### Examples

```javascript
var geojsonRbush = require('geojson-rbush').default;
var tree = geojsonRbush();
```

Returns **RBush** GeoJSON RBush

### insert

[insert][1]

#### Parameters

*   `feature` **[Feature][2]** insert single GeoJSON Feature

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);
tree.insert(poly)
```

Returns **RBush** GeoJSON RBush

### load

[load][3]

#### Parameters

*   `features` **([FeatureCollection][4] | [Array][5]<[Feature][2]>)** load entire GeoJSON FeatureCollection

#### Examples

```javascript
var polys = turf.polygons([
    [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]],
    [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]
]);
tree.load(polys);
```

Returns **RBush** GeoJSON RBush

### remove

[remove][6]

#### Parameters

*   `feature` **[Feature][2]** remove single GeoJSON Feature
*   `equals` **[Function][7]** Pass a custom equals function to compare by value for removal.

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);

tree.remove(poly);
```

Returns **RBush** GeoJSON RBush

### clear

[clear][6]

#### Examples

```javascript
tree.clear()
```

Returns **RBush** GeoJSON Rbush

### search

[search][8]

#### Parameters

*   `geojson` **([BBox][9] | [FeatureCollection][4] | [Feature][2])** search with GeoJSON

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);

tree.search(poly);
```

Returns **[FeatureCollection][4]** all features that intersects with the given GeoJSON.

### collides

[collides][10]

#### Parameters

*   `geojson` **([BBox][9] | [FeatureCollection][4] | [Feature][2])** collides with GeoJSON

#### Examples

```javascript
var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);

tree.collides(poly);
```

Returns **[boolean][11]** true if there are any items intersecting the given GeoJSON, otherwise false.

### all

[all][8]

#### Examples

```javascript
tree.all()
```

Returns **[FeatureCollection][4]** all the features in RBush

### toJSON

[toJSON][12]

#### Examples

```javascript
var exported = tree.toJSON()
```

Returns **any** export data as JSON object

### fromJSON

[fromJSON][12]

#### Parameters

*   `json` **any** import previously exported data

#### Examples

```javascript
var exported = {
  "children": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [110, 50]
      },
      "properties": {},
      "bbox": [110, 50, 110, 50]
    }
  ],
  "height": 1,
  "leaf": true,
  "minX": 110,
  "minY": 50,
  "maxX": 110,
  "maxY": 50
}
tree.fromJSON(exported)
```

Returns **RBush** GeoJSON RBush

[1]: https://github.com/mourner/rbush#data-format

[2]: https://tools.ietf.org/html/rfc7946#section-3.2

[3]: https://github.com/mourner/rbush#bulk-inserting-data

[4]: https://tools.ietf.org/html/rfc7946#section-3.3

[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[6]: https://github.com/mourner/rbush#removing-data

[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function

[8]: https://github.com/mourner/rbush#search

[9]: https://tools.ietf.org/html/rfc7946#section-5

[10]: https://github.com/mourner/rbush#collisions

[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean

[12]: https://github.com/mourner/rbush#export-and-import

[13]: https://github.com/mourner/rbush#rbush

[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->

---

This module is part of the [Turfjs project](https://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 single module individually:

```sh
$ npm install @turf/geojson-rbush
```

Or install the all-encompassing @turf/turf module that includes all modules as functions:

```sh
$ npm install @turf/turf
```

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