Re: gsn_add_polyline in LambertConformal

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Sep 11 2012 - 16:50:44 MDT

All,

Dave said that my new example was misleading, so I decided to remove it. In some cases, the mpGreatCircleLinesOn resource will give you straight lines, but for other cases, you will need to do something like in polyg_13.ncl.

Here is Dave's explanation:

I am worried that your example polyg_15.ncl is misleading. It depends on the projection and the particular endpoints of each line whether setting mpGreatCircleLinesOn to True or False
results in lines that look straight. In your example the second plot does not actually have straight lines, at least for the lines that are close to horizontal. The vertical lines are straight only because they are of constant longitude and it is a characteristic of the lambert conformal projection that lines of constant longitude are straight. It would not be true for other projections.

Try setting
res@mpProjection = "orthographic"
res@mpCenterLonF = -95
res@mpCenterLatF = 0

and you will get a plot where the first frame looks (almost) straight and the second frame looks pretty curved.

I think if you really want straight lines between the points in a projection-independent manner, you need to use datatondc to get the NDC values of the vertexes, and then use gsn_polyline_ndc (or equivalent) to draw the lines.

mpGreatCircleLinesOn set to False produces lines that are straight on a latlon (cylindricalequidistant) plot. But mpGreatCircleLinesOn set to True follows a great circle path (which is the
shortest distance between the points on the surface of sphere). This path only appears straight under certain limited conditions, which are different for each projection.
-dave

On Sep 11, 2012, at 3:19 PM, Mary Haley wrote:

> Try setting:
>
> mpres@mpGreatCircleLinesOn = True
>
> http://www.ncl.ucar.edu/Document/Graphics/Resources/mp.shtml#mpGreatCircleLinesOn
>
> See the new example "polyg_15.ncl" at:
>
> http://www.ncl.ucar.edu/Applications/polyg.shtml
>
> --Mary
>
>
> On Sep 11, 2012, at 12:39 PM, Alexander Cohan wrote:
>
>> Hello,
>>
>> I would like to use
>
>> to draw a straight line in
>> LambertConformal, however the lines are curved. How can I make the
>> lines straight?
>> The NCL script is below.
>>
>> Thanks!
>> Alex
>>
>>
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>>
>> begin
>>
>> wks = gsn_open_wks ("pdf", "DOMAIN3") ; open workstation
>>
>> mpres = True ; plot mods desired
>> mpres@gsnMaximize = True
>> mpres@gsnFrame = False
>> mpres@gsnDraw = False
>>
>> mpres@mpDataBaseVersion = "Ncarg4_1"
>> mpres@vpWidthF = 0.90 ; change aspect ratio of plot
>> mpres@vpHeightF = 0.90
>> mpres@vpXF = 0.05
>>
>> mpres@vpYF = 0.95
>> mpres@gsnMaximize = True
>> mpres@mpFillOn = True
>> mpres@mpLandFillColor = "Background"
>> mpres@mpPerimOn = False
>> mpres@mpOutlineOn = True
>> mpres@mpOutlineBoundarySets = "GeophysicalandUSStates"
>> ;
>> ; Zoom in on United States.
>> ;
>> mpres@mpProjection = "LambertConformal"
>> mpres@mpLambertParallel1F = 33.0
>> mpres@mpLambertParallel2F = 45.0
>> mpres@mpLambertMeridianF = -97.0
>> mpres@mpLimitMode = "LatLon"
>>
>> mpres@mpGridAndLimbOn = True
>> mpres@pmTickMarkDisplayMode = "Always" ; turn on tickmarks
>> mpres@mpGridAndLimbDrawOrder = "PreDraw" ; Draw grid before
>>
>> mpres@mpGridLineThicknessF = 10
>> mpres@mpGridLineColor = "blue"
>> mpres@mpFillColor ="blue"
>>
>> mpres@tiMainString = "CONUS 36km Domain"
>>
>>
>> mpres@mpMinLatF = 18.17032
>> mpres@mpMaxLatF = 53.2662
>> mpres@mpMinLonF = -121.7744
>> mpres@mpMaxLonF = -63.23684
>> mpres@mpGridSpacingF = 0.0555
>> map_thin = gsn_csm_map(wks,mpres)
>>
>>
>> ;draw box 1
>> xbox= (/-98.32171,-98.64162,-75.10528,-79.25256,-98.32171/)
>> ybox= (/35.00315, 49.48106, 47.72993, 33.57016,35.00315/)
>> resA=True
>> resA@gsLineThicknessF = 10.
>> resA@gsLineColor ="red"
>> resA@gsFillOpacityF = 0.9
>> resA@gsMarkerOpacityF =0.1
>> resA@mpProjection = "LambertConformal"
>>
>> dum = new(4,graphic)
>> do i = 0 , 3
>> dum(i)=gsn_add_polyline(wks,map_thin,xbox(i:i+1),ybox(i:i+1),resA)
>> end do
>> draw(map_thin) ; Both maps will get drawn.
>>
>> frame(wks)
>>
>> end
>> _______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Sep 11 16:50:55 2012

This archive was generated by hypermail 2.1.8 : Thu Sep 13 2012 - 14:22:31 MDT