Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geojson-rbush

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojson-rbush

GeoJSON implementation of RBush

  • 3.2.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is geojson-rbush?

The geojson-rbush npm package is a spatial index for GeoJSON objects, built on top of the R-tree data structure. It allows for efficient spatial querying and manipulation of GeoJSON data, such as points, lines, and polygons.

What are geojson-rbush's main functionalities?

Insert GeoJSON objects

This feature allows you to insert GeoJSON objects into the spatial index. The code sample demonstrates how to create a new GeoJSONRBush instance and insert a GeoJSON FeatureCollection into it.

const GeoJSONRBush = require('geojson-rbush');
const tree = GeoJSONRBush();
const geojson = { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } } ] };
tree.insert(geojson);

Search for GeoJSON objects

This feature allows you to search for GeoJSON objects within a specified area. The code sample demonstrates how to search for GeoJSON objects within a given polygon.

const searchArea = { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ] } };
const results = tree.search(searchArea);

Remove GeoJSON objects

This feature allows you to remove GeoJSON objects from the spatial index. The code sample demonstrates how to remove a specific GeoJSON object from the index.

const geojsonToRemove = { "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } };
tree.remove(geojsonToRemove);

Bulk load GeoJSON objects

This feature allows you to bulk load multiple GeoJSON objects into the spatial index. The code sample demonstrates how to load a GeoJSON FeatureCollection into the index in one operation.

const bulkGeojson = { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [102.0, 0.5] }, "properties": { "prop0": "value0" } }, { "type": "Feature", "geometry": { "type": "Point", "coordinates": [103.0, 1.5] }, "properties": { "prop1": "value1" } } ] };
tree.load(bulkGeojson);

Other packages similar to geojson-rbush

Keywords

FAQs

Package last updated on 29 Jul 2021

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