# Re: Simplest way to plot a line

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 11 2013 - 17:28:08 MST

Why are you using 'wrf_user_ll_to_ij' ?

Finds the nearest model grid indices (i,j) to the specified location(s)
in longitude and latitude.

The following is giving model grid index values.
gsn_add_polyline( has no idea how these relate to the real world.

> pt_a = wrf_user_ll_to_ij(d2,-126.0,42.0,True)
> pt_b = wrf_user_ll_to_ij(d2,-121.5,34.9,True)
>
> xpts=(/ pt_a(0), pt_b(0) /)
> ypts=(/ pt_a(1), pt_b(1) /)
>
> dum=new(1,graphic) ;must create dummy

The Polylines examples use lat and lon

Example 4
ypts = (/ 30.0, 30.0, 0.0, 0.0, 30.0/) ; latitudes
xpts = (/-90.0, -45.0,-45.0, -90.0,-90.0/) ; longitudes

Example 14
dum1 = gsn_add_polyline(wks,plot1, (/lon1, lon2/) , (/lat1, lat2/) ,pres)

You want:

lonpts = (/-126.0, -121.5/)
latpts = (/ 42.0, 34.9/)

On 12/11/13, 5:14 PM, A.J. Eiserloh wrote:
> I tried to use gsn_add_polyline but I only see my map and not the line? It
> gives me no errors. Here is my code below:
>
>
>
>
> begin
>
> type="png"
> wks = gsn_open_wks(type, "cx_line1") ; Open graphics file
>
> 00.nc", "r")
>
> terr = wrf_user_getvar(d2,"HGT_M",0)
> lat2 = wrf_user_getvar(d2,"XLAT",0)
> lon2 = wrf_user_getvar(d2,"XLONG",0)
>
> terr@lat2d = lat2
> terr@lon2d = lon2
>
> dom_dims = dimsizes(terr)
> nx2 = dom_dims(1) - 1
> ny2 = dom_dims(0) - 1
>
>
> res = True
>
> ; Set some contouring resources.
> res@cnFillOn = True
> res@cnLinesOn = False
> res@cnLineLabelsOn = False
> res@cnInfoLabelOn = False
> res@cnLevelSelectionMode = "ExplicitLevels"
> res@cnLevels = (/0, 10, 25, 50, 75, 125, 200, 350, 500, 750, \
> 1000, 1250, 1500, 1750, 2000, 2250, 3000/)
> res@gsnLeftString = ""
> res@gsnRightString = ""
>
> res@gsnDraw = False
> res@gsnFrame = False
>
> res@mpDataBaseVersion = "MediumRes" ; Default is LowRes
> res@mpOutlineDrawOrder = "PostDraw" ; Draw map outlines last
> res@mpGridAndLimbOn = True ; Turn off lat/lon lines
> res@mpGridLatSpacingF = 5.0
> res@mpGridLonSpacingF = 5.0
> res@mpGridLineColor = "gray"
> res@mpGridLineDashPattern = 11
> res@pmTickMarkDisplayMode = "Always" ; Turn on map tickmarks
> res = set_mp_wrf_map_resources(d2,res)
> res@mpLimitMode = "Corners" ; Portion of map to zoom
> res@mpLeftCornerLatF = lat2(0,0)
> res@mpLeftCornerLonF = lon2(0,0)
> res@mpRightCornerLatF = lat2(ny2,nx2)
> res@mpRightCornerLonF = lon2(ny2,nx2)
>
> res@tmXTLabelFontHeightF = 0.012
> res@tmXBLabelFontHeightF = 0.012
> res@tmYLLabelFontHeightF = 0.012
> res@tmXTLabelFontHeightF = 0.012
>
> ; Add label bar resources
> res@lbLabelAutoStride = True
> res@gsnMaximize = True ; Maximize plot in frame
> res@pmLabelBarOrthogonalPosF = -0.01
> res@pmLabelBarHeightF = 0.08
> res@lbLabelFontHeightF = 0.01
> res@lbTitleOn = True
> res@lbTitlePosition = "top"
> res@lbTitleString = "Elevation (m)"
> res@lbTitleFontHeightF = 0.01
> res@lbTopMarginF = 0.17
> res@lbTitleOffsetF = 0.01
>
> ; we need these to later draw boxes for the location of the nest domain
> lnres = True
> lnres@gsLineThicknessF = 3.0
> lnres@gsLineColor="black"
>
> ; make images
> map = gsn_csm_contour_map(wks, terr, res)
>
> ;get point A and B
>
> pt_a = wrf_user_ll_to_ij(d2,-126.0,42.0,True)
> pt_b = wrf_user_ll_to_ij(d2,-121.5,34.9,True)
>
> xpts=(/ pt_a(0), pt_b(0) /)
> ypts=(/ pt_a(1), pt_b(1) /)
>
> dum=new(1,graphic) ;must create dummy
>
> draw(map)
> frame(wks)
>
> end
>
>
>
> On Wed, Dec 11, 2013 at 3:55 PM, Dennis Shea <shea@ucar.edu> wrote:
>
>>
>> http://www.ncl.ucar.edu/Applications/
>>
>> Search/Look for something with "lines" ==> Polylines
>>
>> Click
>>
>> http://www.ncl.ucar.edu/Applications/polyg.shtml
>> Example 4
>> Example 14
>>
>>
>>
>>
>>
>> On 12/11/13, 4:42 PM, A.J. Eiserloh wrote:
>>
>>> What is the easiest way to plot a line onto a gsn_csm_contour_map() ? I
>>> have 2 points and I would like to just draw a line through those points.
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> 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 Wed Dec 11 17:28:20 2013

This archive was generated by hypermail 2.1.8 : Fri Dec 13 2013 - 11:39:30 MST