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

which-polygon

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

which-polygon

Index for matching points against a set of GeoJSON polygons

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15K
increased by9.97%
Maintainers
1
Weekly downloads
 
Created
Source

A simple index for matching points against a set of GeoJSON polygons to find what polygon a point belongs to.

For example, given a GeoJSON of world countries, it can be used to determine what country a location belongs to.

Example usage

Using this 50m world countries dataset:

var geojson = require('./countries.json');
var tree = whichPolygon.index(geojson);

whichPolygon.query(tree, [30.5, 50.5]).admin; // 'Ukraine'

The input GeoJSON must be a feature collection of polygons or multipolygons.

Once the index is built, queries are pretty fast — 20 seconds to query 1 million random locations on a Macbook Pro in this particular case.

Keywords

FAQs

Package last updated on 03 Nov 2015

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