On Fri, Jul 15, 2011 at 1:44 PM, Yoshi Rokuko <yo...@rokuko.net> wrote:

> +--------------------------------------------- Jeff Whitaker -----------+
> > On 7/14/11 2:25 PM, Yoshi Rokuko wrote:
> > > hi, is it possible to restrict a contour plot to a
> > > country? if i grid my data to projection coordinates
> > > and then make a contour plot i can draw the country
> > > borders on top, but since the data plotted outside
> > > the country is a gridding artifact i would rather
> > > not plot it.
> >
> > Yoshi:  There is no mechanism for doing this.  It is possible, but you
> > would need a way to create a mask for all the grid points outside the
> > country of interest, and then use this mask to create a masked array to
> > pass to contourf.
> >
> > -Jeff
>
> wouldn't it be possible to create such a mask using internals from
> Basemap.drawcountries() somehow?
>
> best regards, yoshi
>
>
Jeff, I just had a thought....

Isn't the country borders drawn as Path or Polygon objects?  I believe there
are some matplotlib internal functions that can be given a list of points
(such as those for a grid) and a path and it will return which points are
within the path and which are outside.  One could use that to make the mask.

Might make for a nice feature for basemap in the upcoming v1.1.0 release.

Ben Root
------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to