pysal.lib.cg.get_rectangle_rectangle_intersection

pysal.lib.cg.get_rectangle_rectangle_intersection(r0, r1, checkOverlap=True)[source]

Returns the intersection between two rectangles.

Note: Algorithm assumes the rectangles overlap.
checkOverlap=False should be used with extreme caution.

get_rectangle_rectangle_intersection(r0, r1) -> Rectangle, Segment, Point or None

Parameters:
r0 : a Rectangle
r1 : a Rectangle

Examples

>>> r0 = Rectangle(0,4,6,9)
>>> r1 = Rectangle(4,0,9,7)
>>> ri = get_rectangle_rectangle_intersection(r0,r1)
>>> ri[:]
[4.0, 4.0, 6.0, 7.0]
>>> r0 = Rectangle(0,0,4,4)
>>> r1 = Rectangle(2,1,6,3)
>>> ri = get_rectangle_rectangle_intersection(r0,r1)
>>> ri[:]
[2.0, 1.0, 4.0, 3.0]
>>> r0 = Rectangle(0,0,4,4)
>>> r1 = Rectangle(2,1,3,2)
>>> ri = get_rectangle_rectangle_intersection(r0,r1)
>>> ri[:] == r1[:]
True