Pk19000 Pk19000 - 2 months ago 42
Python Question

The area of the intersection of two ovals (ellipses)?

I need to calculate the amount of two oval intersects in a python program.
I know in shaply there is a function that return true if two object has intersects. As like as this:

from shapely.geometry import Polygon
p1=Polygon([(0,0),(1,1),(1,0)])
p2=Polygon([(0,1),(1,0),(1,1)])
print p1.intersects(p2)


is there any library or function That help me?
Thanks.

Answer

Is this what you are looking for? (the polygon that results from the intersection)

x = p1.intersection(p2)
x.area

Find more information in the documentation here