Hi, wonder if anyone can help me with path and bbox.  I have a set of ocean
drifter tracks and I want to know if they pass through a particular boxed
area.  This is straightforward to do but I wanted to try to do it with
matplotlib.transforms and matplotlib.path, which look well-suited to this
kind of task using 'intersects_bbox'.

The essence of my code is below.  I have a single drifter track (lon, lat)
and have defined a boxed area.  At no time does the drifter approach or
enter the box - however, the final line,

    print track.intersects_bbox(bbox)

returns True, which it shouldn't.  In total I have 340 tracks.  My code says
74 pass though the box, but by counting there should be only about 9.  Any
help appreciated, thanks, Evan


import numpy as N
import numpy.ma as MA
import matplotlib.transforms as BB
import matplotlib.path as PP

In [200]: lon
Out[200]:
masked_array(data = [-15.52 -15.521 -15.541 ..., -- -- --],
      mask = [False False False ...,  True  True  True],
      fill_value=1e+20)

In [201]: lat
Out[201]:
masked_array(data = [29.2 29.2 29.196 ..., -- -- --],
      mask = [False False False ...,  True  True  True],
      fill_value=1e+20)

In [202]: len(lon), len(lat)
Out[202]: (3750, 3750)

track = MA.transpose([lon, lat])
track = PP.Path(track)
bbox = BB.Bbox.from_extents(-15.95, 29.6, -15.9, 29.65)

In [206]: print track.intersects_bbox(bbox)
1
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to