Skip to content Skip to sidebar Skip to footer

Openlayers 3, Area Intersection Between Geometries

I'm evaluating if OpenLayers3 would serve us to develop some tools we need on our day to day basis and I'm getting stuck with one feature that I supose it has to exist but I cannot

Solution 1:

OpenLayers 3 itself does not provide functions to calculate the intersection between polygons. But it is relatively straightforward to use Turf.js with ol3:

var polygon1 = new ol.Feature(new ol.geom.Polygon(...));
var polygon2 = new ol.Feature(new ol.geom.Polygon(...));

var format = new ol.format.GeoJSON();
var intersection = format.readFeature(
    turf.intersect(
        format.writeFeatureObject(polygon1),
        format.writeFeatureObject(polygon2)));

http://jsfiddle.net/d6o81vc7/

Post a Comment for "Openlayers 3, Area Intersection Between Geometries"