finding the intersection of 2 rectangles

Is there an easy way to find the locations in rectangle1 that are covered by rectangle2? I couldn’t find this anywhere.

Mathew

···

Mathew Yeates wrote:

Is there an easy way to find the locations in rectangle1 that are covered by rectangle2? I couldn't find this anywhere.

Mathew

Mathew: There's nothing included in matplotlib - I recommend Shapely (http://trac.gispython.org/lab/wiki/Shapely). It's an interface to the GEOS library, which you already have since you have basemap. Basemap includes it's own private interface to GEOS, but Shapely has a much better (although slower), well documented API.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/PSD1 FAX : (303)497-6449
325 Broadway Boulder, CO, USA 80305-3328

Mathew Yeates wrote:

Is there an easy way to find the locations in rectangle1 that are covered by rectangle2? I couldn't find this anywhere.

Mathew: There's nothing included in matplotlib - I recommend Shapely (http://trac.gispython.org/lab/wiki/Shapely). It's an interface to the GEOS library, which you already have since you have basemap. Basemap includes it's own private interface to GEOS, but Shapely has a much better (although slower), well documented API.

But with ordinary rectangles (with sides parallel
to the axes), if you can extract their
coordinates/size, the analytical problem is trivial:
use this info to get the overlap along each axis.
If the rectangles share a common transform,
this is still pretty easy. So you may be able
to avoid a more general solution.

I've interpreted the question one way: "covered"
might suggest you additionally need the z-order.

Cheers,
Alan Isaac

···

On 10/20/2008 7:46 AM Jeff Whitaker apparently wrote: