Re: Add points of interes to a background map

From: Jing Zheng <jingzheng.bj_at_nyahnyahspammersnyahnyah>
Date: Fri Aug 26 2011 - 09:23:53 MDT

Hi all,

I am not quite familiar with NCL. I met a similar problem with this.
I followed this Q&A but still was not very clear how to figure out my
problem.

I just wanted to add 1 point of location into the plot, but failed to add
the point.

I didn't call any NCL procedure. But I added a few lines in the scripts as
follow:

---------------------------
plot = wrf_map_overlays(a1,wks,(/diff_tc,diff_slp,diff_gh/),pltres,mpres)
doto=gsn_add_polymarker(wks,plot,xxo,yyo,gsres)
frame(wks)
--------------------------

Any suggestion? Thanks.

Jing

On Fri, Aug 26, 2011 at 3:37 AM, Adam Phillips <asphilli@ucar.edu> wrote:

> Hi Vanesa,
> The order of calling gsn_polyline/gsn_add_polymarker is critically
> important. Coding from my last email:
>
> pltres@PanelPlot = True ; = gsnFrame,gsnDraw = False
> ........
> plot = wrf_map_overlays(....,pltres,mpres)
> call gsn_add_polymarker/gsn_add_text (=call draw_shapefile_lines_p)
> draw(plot)
> draw_shapefile_lines(wks,plot) ; use gsn_polyline
> frame(wks)
>
> What you just sent:
>
> pltres@PanelPlot = True ; = gsnFrame,gsnDraw = False
> ........
> plot = wrf_map_overlays(....,pltres,mpres)
> draw(plot)
> call gsn_add_polymarker/gsn_add_text (=call draw_shapefile_lines_p)
> draw_shapefile_lines(wks,plot) ; use gsn_polyline
> frame(wks)
>
> Beyond your ordering issue, the draw_shapefile_lines_p procedure needs
> to be slightly modified.
> You are creating a blank plot within the procedure:
> map = gsn_csm_map(wks,res)
>
> But you don't need to do that as you have passed in your original plot
> into the procedure:
> procedure draw_shapefile_lines_p(wks,plot)
>
> Thus, you can remove all references to the res resource list and map
> (=lines 32-50)... You will also want to change all references from map
> to plot (=lines 98, 109)... Finally, remove draw(map) and frame(wks).
> You do not want to draw the plot or advance the frame within this
> procedure...
>
> Thus, your procedure should look something like this:
>
> procedure draw_shapefile_lines_p(wks,plot)
> begin
> f = addfile("JUJUY-Points.shp","r")
> print("Reading 'JUJUY-Points.shp'")
> prims = True
> names = f->NAME
> .......... (skipping forward, keep all coding here the same)
>
> prims@$dumstr$ = gsn_add_polymarker(wks, plot, lon(i), lat(i), mkres)
> .......... (skipping forward, keep all coding here the same)
>
> prims@$dumstr$ = gsn_add_text(wks, plot, " " + names(i), \
> lon(i), lat(i), txres)
> delete(ii)
> end if
> end do
> end
>
> Let ncl-talk know if reordering the calling of various procedures within
> aeronavegacion_300.ncl and modifying shapefiles_points_faster.ncl
> doesn't work.. Adam
>
> On 08/25/2011 12:54 PM, Vanesa Bdm wrote:
> > Adam, I been trying to do what you said.
> > I modified the scripts.
> > I attach them and the final image, now I can draw everything, But
> > instead of points on the map, they shown in another image.
> > I attach image of that too.
> >
> > Thanks
> >
> >
> > > Date: Wed, 24 Aug 2011 10:08:58 -0600
> > > From: asphilli@ucar.edu
> > > To: ncl-talk@ucar.edu
> > > Subject: Re: Add points of interes to a background map
> > >
> > > Hi Vanesa,
> > > I wasn't as clear in my original response as I should have been.
> Here's
> > > the order of things you should do in order for everything to draw:
> > >
> > > pltres@PanelPlot = True ; = gsnFrame,gsnDraw = False
> > > ........
> > > plot = wrf_map_overlays(....,pltres,mpres)
> > > call gsn_add_polymarker/gsn_add_text for polymarkers/text
> > > draw(plot)
> > > draw_shapefile_lines(wks,plot) ; use gsn_polyline
> > > frame(wks)
> > >
> > > The reason for that order: Anytime you use gsn_add_* functions they
> need
> > > to be called before the plot is drawn and the frame is advanced. If
> you
> > > do not do that the gsn_add_* output will not be added to the plot.
> > > gsn_polyline (which draw_shapefile_lines uses) on the other hand,
> needs
> > > the plot to be drawn before it is called.
> > >
> > > I would recommend simplifying your script to test this out. Create the
> > > plot, manually call gsn_add_polymarker, call draw, then manually call
> > > gsn_polyline, then call frame..
> > >
> > > Hope that all makes sense.. If you continue to have issues please send
> > > ncl-talk the latest version of all three of your scripts...
> > > Adam
> > >
> > > On 08/24/2011 08:34 AM, Vanesa Bdm wrote:
> > > > Hi Adam, thanks for the answer.
> > > > I can't make this work.
> > > > I have 3 shapefiles, a map, a poligon and points of interest.
> > > > I can draw map and poligon but I can't add the points of interest.
> > > > If you see the shapefile script MAry worte a function there that I
> call
> > > > from aeronavegacion, I load the 2 shapefiles and draw them ok, but
> how
> > > > can I add the points also?
> > > > I attach an image of the map and poligon so you can see that.
> > > >
> > > > Cheers
> > > >
> > > > > Date: Fri, 19 Aug 2011 14:49:42 -0600
> > > > > From: asphilli@ucar.edu
> > > > > To: ncl-talk@ucar.edu
> > > > > Subject: Re: Add points of interes to a background map
> > > > >
> > > > > You're having trouble with shapefiles_point.ncl, correct?
> > > > >
> > > > > If so, then I think I know what the problem is. You need to add:
> > > > > res@gsnDraw = False ; do not draw the plot
> > > > > res@gsnFrame = False ; do not advance the frame (=flip the page)
> > > > >
> > > > > You correctly call draw(map) and frame(wks) after the polymarkers
> are
> > > > > drawn, but you need to tell NCL to not draw the plot or advance
> the
> > > > > frame until the polymarkers are drawn. Without that, any
> polymarkers
> > > > > will not be added properly.
> > > > >
> > > > > Note that in your aeornavegacion_300.ncl script, you set
> > > > > pltres@PanelPlot = True. What this does (behind the scenes) is to
> set
> > > > > gsnDraw = False and gsnFrame = False when you call the WRF
> plotting
> > > > > function wrf_map_overlays, which again is a necessary precondition
> to
> > > > > using any of the gsn_add_* functions..
> > > > >
> > > > > Hope that helps! Adam
> > > > >
> > > > > On 08/19/2011 02:14 PM, Vanesa Bdm wrote:
> > > > > > Hello a few months ago, Mary and Dennis help me to add a
> > backgrond map
> > > > > > to my scripts.
> > > > > > Now I need to add towns (points of interest).
> > > > > > I can do exactly that but separetly, I edit shapiles_6.ncl and I
> > > > can see
> > > > > > all my points, and I try, but with no success to add those
> > points to my
> > > > > > script so I can see all together.
> > > > > >
> > > > > > Any ideas?
> > > > > >
> > > > > > Cheers
> > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > ncl-talk mailing list
> > > > > > List instructions, subscriber options, unsubscribe:
> > > > > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > > >
> > > > > --
> > > > > ______________________________________________________________
> > > > > Adam Phillips asphilli@ucar.edu
> > > > > NCAR/Climate and Global Dynamics Division (303) 497-1726
> > > > > P.O. Box 3000
> > > > > Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
> > > > > _______________________________________________
> > > > > ncl-talk mailing list
> > > > > List instructions, subscriber options, unsubscribe:
> > > > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > ncl-talk mailing list
> > > > List instructions, subscriber options, unsubscribe:
> > > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> > >
> > > --
> > > ______________________________________________________________
> > > Adam Phillips asphilli@ucar.edu
> > > NCAR/Climate and Global Dynamics Division (303) 497-1726
> > > P.O. Box 3000
> > > Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
> > > _______________________________________________
> > > ncl-talk mailing list
> > > List instructions, subscriber options, unsubscribe:
> > > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> >
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> --
> ______________________________________________________________
> Adam Phillips asphilli@ucar.edu
> NCAR/Climate and Global Dynamics Division (303) 497-1726
> P.O. Box 3000
> Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Fri Aug 26 09:24:01 2011

This archive was generated by hypermail 2.1.8 : Mon Aug 29 2011 - 21:44:22 MDT