Skip to content

Commit 29f85e5

Browse files
committed
add a readme
1 parent 31db2d9 commit 29f85e5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
A simple index for matching points against a set of GeoJSON polygons to find what polygon a point belongs to.
2+
3+
For example, given a GeoJSON of world countries, it can be used to determine what country a location belongs to.
4+
5+
6+
### Example usage
7+
8+
Using [this 50m world countries dataset](https://s3.amazonaws.com/geojson-please/naturalearth-3.3.0/ne_50m_admin_0_countries.geojson):
9+
10+
```js
11+
var geojson = require('./countries.json');
12+
var tree = whichPolygon.index(geojson);
13+
14+
whichPolygon.query(tree, [30.5, 50.5]).admin; // 'Ukraine'
15+
```
16+
17+
The input GeoJSON must be a feature collection of polygons or multipolygons.
18+
19+
Once the index is built, queries are pretty fast —
20+
20 seconds to query 1 million random locations on a Macbook Pro in this particular case.

0 commit comments

Comments
 (0)