Greiner-Hormann polygon clipping algorithm. Does AND, OR, XOR. Plays nicely with Leaflet. Handles non-convex polygons and multiple clipping areas. ~3kb footprint, no dependencies
JavaScript Makefile HTML CSS
Latest commit 13329de Aug 22, 2016 @w8r 1.3.1
Failed to load latest commit information.
dist fixed make Aug 22, 2016
lib initial commit Aug 4, 2014
src typo, bundle Dec 10, 2014
test fixed make Aug 22, 2016
.gitignore typo, bundle Dec 10, 2014
LICENSE Update LICENSE Oct 12, 2015
Makefile fixed make Aug 22, 2016 Update Aug 9, 2016
bower.json bower Oct 17, 2015
package.json 1.3.1 Aug 22, 2016


Greiner-Hormann polygon clipping

  • Does AND, OR, XOR (intersection, union, difference, if you're human)
  • Plays nicely with Leaflet, comes with an adaptor for it
  • Handles non-convex polygons and multiple clipping areas
  • ~3kb compressed, no dependencies

Demo and documentation

Note: If you are looking for something more powerful, take a look at the Martinez polygon clipping implementation.


$ npm install greiner-hormann


var greinerHormann = require('greiner-hormann');


<script src="path/to/greiner-hormann(.leaflet).min.js"></script>


var intersection = greinerHormann.intersection(source, clip);
var union        = greinerHormann.union(source, clip);
var diff         = greinerHormann.diff(source, clip);


    if(typeof intersection[0][0] === 'number'){ // single linear ring
        intersection = [intersection];
    for(var i = 0, len = intersection.length; i < len; i++){
        L.polygon(intersection[i], {...}).addTo(map);


Input and output can be {x:x, y:y} objects or [x,y] pairs. It will output the points in the same format you put in.