Re: Polygon use on map, multiple boxes

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 21 Jul 2008 14:11:39 -0600 (MDT)

Erik,

You need to have a unique variable for every single time
you call gsn_add_polyxxxx.

In your code below, you use "dum" three different times. I would
change this to three separate arrays: "dum1", "dum2", and "dum3" and
it should work.

I will add this to our FAQ, which is new and being added to:

    http://www.ncl.ucar.edu/FAQ/

--Mary

On Mon, 21 Jul 2008, Erik Noble wrote:

> Dear NCL, I tried using the polygon example
> http://www.ncl.ucar.edu/Applications/Scripts/polyg_4.ncl
> to place several boxes over a map. It worked for the first box, yet
> when I try to place two more boxes on the map, I get these errors
> regarding elements. Could I have some advice on how to get past these
> errors? I looked in the ncl archives and I don't see any question like
> this. Code and terminal history are below.
>
> Thank you in advance
> Erik
>
>
> ;================================================;
> ; maponly_2.ncl
> ;================================================;
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> ; ================================================;
> begin
> wks = gsn_open_wks("ps","maponly") ; open a ps file
> res = True
> res_at_pmTickMarkDisplayMode = "Always" ; turn on built-in tickmar
> res_at_gsnDraw = False ; don't draw yet
> res_at_gsnFrame = False ; don't advance yet
> res_at_mpFillOn = False ; turn off gray fill
> res_at_mpOutlineBoundarySets = "National" ; turn on country boundaries
> res_at_mpGeophysicalLineColor = "Navy" ; color of cont. outlines
> res_at_mpGeophysicalLineThicknessF = 1.5 ; thickness of outlines
> ; res_at_gsnMaximize = True
> res_at_mpGridSpacingF = 0.50
> res_at_mpMaxLatF = 35 ; choose subregion
> res_at_mpMinLatF = -20
> res_at_mpMaxLonF = 35
> res_at_mpMinLonF = -35
> plot = gsn_csm_map_ce(wks,res) ; draw map
>
> ;************************************************
> ; create points for box1
> ;************************************************
> ypts = (/ 18.0, 18.0, 5.0, 5.0, 18.0/)
> xpts = (/-30.0, -20.0,-20.0, -30.0,-30.0/)
> ;************************************************
> ; add the box
> ;************************************************
> res1 = True ; polyline mods desired
> res1_at_gsLineColor = "red" ; color of lines
> res1_at_gsLineThicknessF = 2.0 ; thickness of lines
> res1_at_gsLineLabelString= "L1" ; adds a line label string
>
> ; create array of dummy graphic variables. This is required, b/c each line
> ; must be associated with a unique dummy variable.
>
> dum = new(4,graphic)
> ; draw each line separately. Each line must contain two points.
> do i = 0 , 3
> dum(i)=gsn_add_polyline(wks,plot,xpts(i:i+1),ypts(i:i+1),res1)
> end do
> ;************************************************
> ; label the box with additional text
> ;************************************************
> tres = True
> tres_at_txFontHeightF = 0.02
> gsn_text(wks,plot,"L1",-25.0,12.0,tres)
>
> draw(plot)
> frame(wks)
> delete(xpts)
> delete(ypts)
> delete(dum)
> ;************************************************
> ; create points for box2
> ;************************************************
> ypts = (/ 18.0, 18.0, 5.0, 5.0, 18.0/)
> xpts = (/-20.0, -10.0,-10.0, -20.0,-20.0/)
> ;************************************************
> ; add the box
> ;************************************************
> res2 = True ; polyline mods desired
> res2_at_gsLineColor = "red" ; color of lines
> res2_at_gsLineThicknessF = 2.0 ; thickness of lines
> res2_at_gsLineLabelString= "L2" ; adds a line label string
>
> ; create array of dummy graphic variables. This is required, b/c each line
> ; must be associated with a unique dummy variable.
>
> dum = new(4,graphic)
> ; draw each line separately. Each line must contain two points.
> do i = 0 , 3
> dum(i)=gsn_add_polyline(wks,plot,xpts(i:i+1),ypts(i:i+1),res2)
> end do
> ;************************************************
> ; label the box with additional text
> ;************************************************
> tres2 = True
> tres2_at_txFontHeightF = 0.02
> gsn_text(wks,plot,"L2",-15.0,12.0,tres2)
>
> draw(plot)
> frame(wks)
> delete(xpts)
> delete(ypts)
> delete(dum)
>
>
> ;create points for box3
> ;************************************************
> ypts = (/ 18.0, 18.0, 5.0, 5.0, 18.0/)
> xpts = (/-10.0, 10.0,10.0, -10.0,-10.0/)
> ;************************************************
> ; add the box
> ;************************************************
> res3 = True ; polyline mods desired
> res3_at_gsLineColor = "red" ; color of lines
> res3_at_gsLineThicknessF = 2.0 ; thickness of lines
> res3_at_gsLineLabelString= "L3" ; adds a line label string
>
> ; array of dummy graphic variables. This is required, b/c each line
> ; be associated with a unique dummy variable.
>
> dum = new(4,graphic)
> ; draw each line separately. Each line must contain two points.
> do i = 0 , 3
> dum(i)=gsn_add_polyline(wks,plot,xpts(i:i+1),ypts(i:i+1),res3)
> end do
> ;************************************************
> ; label the box with additional text
> ;************************************************
> tres2 = True
> tres2_at_txFontHeightF = 0.02
> gsn_text(wks,plot,"L2",-15.0,12.0,tres2)
>
> draw(plot)
> frame(wks)
>
> delete(xpts)
> delete(ypts)
> delete(dum)
>
> end
>
> "makemap.ncl" 129 lines, 5085 characters
>
>
>
> ENOBLE_at_ATHENA: /usr/people/enoble> ncl makemap.ncl
> Copyright (C) 1995-2007 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 4.3.1
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> warning:TransformPostDraw: tfPolyDrawList element 0 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 1 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 2 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 3 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 0 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 1 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 2 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 3 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 4 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 5 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 6 is invalid
> warning:TransformPostDraw: tfPolyDrawList element 7 is invalid
> ENOBLE_at_ATHENA: /usr/people/enoble>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 21 2008 - 14:11:39 MDT

This archive was generated by hypermail 2.2.0 : Mon Jul 21 2008 - 14:41:34 MDT