A high-performance JavaScript R-tree-based 2D spatial index for points and rectangles.
RBush is a high-performance JavaScript library for 2D spatial indexing of points and rectangles using an R-tree data structure. It solves the problem of efficiently querying spatial data, such as finding all items within a bounding box, which is hundreds of times faster than iterating over all items manually. This makes it ideal for applications requiring real-time spatial searches, like interactive maps or complex data visualizations.
JavaScript developers building interactive maps, data visualizations, or any application requiring fast 2D spatial queries, particularly those working with large datasets of points or rectangles.
Developers choose RBush for its optimized R-tree implementation, which offers significant performance gains over alternatives, along with features like bulk insertion, customizable data formats, and easy serialization. Its focus on practical efficiency and proven algorithms makes it a reliable choice for demanding spatial indexing tasks.
RBush — a high-performance JavaScript R-tree-based 2D spatial index for points and rectangles
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Benchmarks show up to 50x faster searches than naive loops and significant improvements over older R-tree implementations, making it ideal for real-time applications like maps.
Bulk insertion is 2-3x faster than individual inserts, and bulk loading into an empty tree improves subsequent query performance by 20-30%, as documented in the README.
Customizable via method overrides like toBBox and compareMinX to support various data structures, such as [x, y] arrays, beyond the default object format.
JSON export/import allows seamless transfer of indexed trees between server and client, facilitating efficient data synchronization without re-indexing.
Version 4+ dropped CommonJS support, which can cause integration issues in legacy Node.js environments or projects not yet migrated to ES modules.
Bulk inserting into an existing tree with scattered data can worsen query performance, as noted in the README, requiring careful data management to avoid slowdowns.
Features like K-nearest neighbors require additional libraries like rbush-knn, adding dependency management overhead rather than being included out-of-the-box.