Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including robust-point-in-polygon with all npm packages installed. Try it out:

var robustPointInPolygon = require("robust-point-in-polygon")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

robust-point-in-polygon v1.0.3

Exactly test if a point is inside, outside or on the boundary of a polygon


Exactly determines if a point is contained in a 2D polygon.


var classifyPoint = require("robust-point-in-polygon")
var polygon = [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ]

  classifyPoint(polygon, [1.5, 1.5]),
  classifyPoint(polygon, [1, 2]),
  classifyPoint(polygom, [100000, 10000]))


-1 0 1


npm install robust-point-in-polygon


require("robust-point-in-polygon")(loop, point)

Tests if a point is contained in the interior of a simple polygon

  • loop is an array of vertices for the polygon
  • point is a 2D point which is classified against the polygon

Returns An integer which determines the position of point relative to polygon. This has the following interpretation:

  • -1 if point is contained inside loop
  • 0 if point is on the boundary of loop
  • 1 if point is outside loop


(c) 2014 Mikola Lysenko. MIT License

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free