Indexed geospatial functions for Node.js, built using Turf, rbush and rbush-knn.
Installation:
npm install nypl-spacetime/indexed-geo
Usage:
const IndexedGeo = require('indexed-geo')
const polygons = JSON.parse(fs.readFileSync('polygons.geojson'))
const point = {
type: 'Point',
coordinates: [
-73.954875,
40.733697
]
}
const indexedGeo = IndexedGeo()
indexedGeo.index(polygons)
const results = indexedGeo.intersects(point)
// results now contains all the polygons intersecting with point
Indexes GeoJSON object.
Searches the index and returns all objects of which the bounding box intersects with point
.
Finds all indexed objects which intersect point
.
Finds k
nearest neighbors. See rbush-knn's documentation for details.