1

Is it possible to calculate the overlapping percentage of two polygons coming from web feature service?

I overlayed two WFS layers in my openlayers map. The two layers have same data but collected at different timespan.So, even though they are same data, there is a change in the polygon area and shape.

I want to calculate the percentage of overlap of corresponding polygons in these two layers.

Is there any api to calculate for such cases?

I heard about Turf.js, intersect.js but couldn't get the right solution for my problem.

1

You probably want turf-union:

Find the union of geographic features

turf.union(poly1, poly2)

Takes two Polygon|polygons and returns a combined polygon. If the input polygons are not contiguous, this function returns a MultiPolygon feature.

I think it even allows for the corner case where the union of the polygons is disjoint. You will then need to determine the percentage of overlap. Take the output of turf.union, get its area (with turf-area), and the area of one of your input polygons, and produce a percentage.

  • Thanks for your reply. I was wondering it turf.union is possible with the polygons returned from WFS request? I have just the bounding boxes of the polygon, can I compute the union and find the area with that information? – ChukkA Mar 15 '16 at 20:21
  • Yes, it works with GeoJSON, and you should b able to get a WFS request to return GeoJSON. – Richard Law Mar 15 '16 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.