libpysal.cg.get_rectangle_rectangle_intersection¶
- libpysal.cg.get_rectangle_rectangle_intersection(r0, r1, checkOverlap=True)[source]¶
Returns the intersection between two rectangles.
- Parameters:
- r0
libpysal.cg.Rectangle
A rectangle to check for an intersection.
- r1
libpysal.cg.Rectangle
A rectangle to check for an intersection against
r0
.- checkOverlapbool
Call
bbcommon(r0, r1)
prior to complex geometry checking. Default isTrue
. Prior to setting asFalse
see the Notes section.
- r0
- Returns:
- intersection{
libpysal.cg.Point
,libpysal.cg.LineSegment
,libpysal.cg.Rectangle
,None
} The intersecting point, line, or rectangle between
r0
andr1
if an intersection exists orNone
ifr0
andr1
do not intersect.
- intersection{
Notes
The algorithm assumes the rectangles overlap. The keyword
checkOverlap=False
should be used with extreme caution.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