Re: overlay different maps

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed, 22 Aug 2007 10:25:09 -0600 (MDT)

> hi,
>
> is it possible to overlay to different contour_map plot? generic overlay
> function does not allow this kind of plot.
>
> best regards,
>
> ufuk utku turuncoglu

>

Hi Ufuk,

I'm not sure what you mean by "different contour_map plot". I believe
once you've overlaid an object on another one, you can't then overlay
it on different one. You will need to recreate it.

That is, if you have something like this:

   map1 = Ngl.map(wks,res1)
   map2 = Ngl.map(wks,res2)
   contour = Ngl.contour(wks,t,cnres)
   Ngl.overlay(map1,contour)

You can't then do this:

   Ngl.overlay(map2,contour)

as you will get an error:

    fatal:NhlAddOverlay: tranform is already an annotation or overlay: 84

You will instead need to do this:

   map1 = Ngl.map(wks,res1)
   map2 = Ngl.map(wks,res2)
   contour1 = Ngl.contour(wks,t,cnres) ; contour1 and contour2
   contour2 = Ngl.contour(wks,t,cnres) ; are identical
   Ngl.overlay(map1,contour1)
   Ngl.overlay(map2,contour2)

Some more background: when you call Ngl.contour_map, what's returned
is effectively the id for the map plot. Since you can't overlay one
map on another map, you can't overlay two Ngl.contour_maps on each
other.

You don't really need to generate the map multiple times anyway. What
you want to do is generate a map plot once, with a call to something
like Ngl.contour_map or Ngl.map, and then generate the second plot you
want to overlay with a call to something like Ngl.contour.

Please see the "overlay1.py" example at:

   http://www.pyngl.ucar.edu/Examples/gallery.shtml

In this script you will see the code:

map_plot = Ngl.map(wks,mpres)
vector_plot = Ngl.vector(wks,ua,va,vcres)
line_contour_plot = Ngl.contour(wks,pa,clres)
fill_contour_plot = Ngl.contour(wks,ta,cfres)
#
# Overlay everything on the map plot.
#
Ngl.overlay(map_plot,fill_contour_plot)
Ngl.overlay(map_plot,line_contour_plot)
Ngl.overlay(map_plot,vector_plot)

Note that the map_plot is being used as the base for all of the
overlays. This is necessary when you do overlays involving a map.

--Mary

On Wed, 22 Aug 2007, [BE] Ufuk Utku Turuncoglu wrote:

_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Wed Aug 22 2007 - 10:25:09 MDT

This archive was generated by hypermail 2.2.0 : Thu Aug 23 2007 - 10:48:58 MDT