comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Plot curved line on a globe projection
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Plot curved line on a globe projection [message #85346] Sun, 28 July 2013 11:19 Go to next message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
Hi all,

I want to plot some straight line sections on a gridded globe plot (i.e. a line joining two points with different lat/lon coordinates), but want these lines to follow the curve of the globe.

I did a test (which I thought would work!) using the following code, but it just plots a straight line:

;Coordinates etc
latcentre = 30
loncentre = 0
angle = 0

;Plot globe
set_plot, 'ps'
!p.font=0
device, /encap, xsize=6, ysize=6, /inches
loadct, 0
map_set, latcentre, loncentre, angle, $
/orthographic, /isotropic, /grid, /horizon, /noborder
map_grid, latdel=5, londel=5, glinestyle=0, glinethick=0.5, color=cgcolor('black')
oplot, [10,30], [30,50], color=cgcolor('black')
device, /close

Can anyone offer any help? Is there anything simple I'm missing? I've searched online, but only seem to be able to find posts related to contouring on globe plots.

Many thanks,

Liam
Re: Plot curved line on a globe projection [message #85347 is a reply to message #85346] Sun, 28 July 2013 12:16 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ljs15@fsmail.net writes:

> I want to plot some straight line sections on a gridded globe plot (i.e. a line joining two points with different lat/lon coordinates), but want these lines to follow the curve of the globe.
>
> I did a test (which I thought would work!) using the following code, but it just plots a straight line:
>
> ;Coordinates etc
> latcentre = 30
> loncentre = 0
> angle = 0
>
> ;Plot globe
> set_plot, 'ps'
> !p.font=0
> device, /encap, xsize=6, ysize=6, /inches
> loadct, 0
> map_set, latcentre, loncentre, angle, $
> /orthographic, /isotropic, /grid, /horizon, /noborder
> map_grid, latdel=5, londel=5, glinestyle=0, glinethick=0.5, color=cgcolor('black')
> oplot, [10,30], [30,50], color=cgcolor('black')
> device, /close
>
> Can anyone offer any help? Is there anything simple I'm missing? I've searched online, but only seem to be able to find posts related to contouring on globe plots.

You can use Map_2Points to get the points making up a great circle
route, but there won't be much difference. Here is an example. The green
line is a straight line, the red is equally spaced in distance, and the
blue is equally spaced in longitude.

;Coordinates etc
latcentre = 30
loncentre = 0
angle = 0

;Plot globe
;set_plot, 'ps'
;!p.font=0
;device, /encap, xsize=6, ysize=6, /inches
cgdisplay, 600, 600
loadct, 0
cgmap_set, latcentre, loncentre, angle, limit=[30, 0, 50, 40], $
/orthographic, /isotropic, /horizon, /noborder
cgmap_grid, latdel=5, londel=5, glinestyle=0, glinethick=0.5
cgPlotS, [10,30], [30,50], Color='grn7'; Straight line.
cgPlotS, Map_2Points(10, 30, 30, 50, DPath=1, NPath=50), $
Color='red' ; Evenly spaced in distance
cgPlotS, Map_2Points(10, 30, 30, 50, /RHUMB, NPath=50), $
Color='blue' ; Evenly spaced in longitude.
;device, /close
END

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Plot curved line on a globe projection [message #85349 is a reply to message #85347] Sun, 28 July 2013 13:00 Go to previous messageGo to next message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
On Sunday, 28 July 2013 20:16:49 UTC+1, David Fanning wrote:
> ljs15@fsmail.net writes:
>
>
>
>> I want to plot some straight line sections on a gridded globe plot (i.e. a line joining two points with different lat/lon coordinates), but want these lines to follow the curve of the globe.
>
>>
>
>> I did a test (which I thought would work!) using the following code, but it just plots a straight line:
>
>>
>
>> ;Coordinates etc
>
>> latcentre = 30
>
>> loncentre = 0
>
>> angle = 0
>
>>
>
>> ;Plot globe
>
>> set_plot, 'ps'
>
>> !p.font=0
>
>> device, /encap, xsize=6, ysize=6, /inches
>
>> loadct, 0
>
>> map_set, latcentre, loncentre, angle, $
>
>> /orthographic, /isotropic, /grid, /horizon, /noborder
>
>> map_grid, latdel=5, londel=5, glinestyle=0, glinethick=0.5, color=cgcolor('black')
>
>> oplot, [10,30], [30,50], color=cgcolor('black')
>
>> device, /close
>
>>
>
>> Can anyone offer any help? Is there anything simple I'm missing? I've searched online, but only seem to be able to find posts related to contouring on globe plots.
>
>
>
> You can use Map_2Points to get the points making up a great circle
>
> route, but there won't be much difference. Here is an example. The green
>
> line is a straight line, the red is equally spaced in distance, and the
>
> blue is equally spaced in longitude.
>
>
>
> ;Coordinates etc
>
> latcentre = 30
>
> loncentre = 0
>
> angle = 0
>
>
>
> ;Plot globe
>
> ;set_plot, 'ps'
>
> ;!p.font=0
>
> ;device, /encap, xsize=6, ysize=6, /inches
>
> cgdisplay, 600, 600
>
> loadct, 0
>
> cgmap_set, latcentre, loncentre, angle, limit=[30, 0, 50, 40], $
>
> /orthographic, /isotropic, /horizon, /noborder
>
> cgmap_grid, latdel=5, londel=5, glinestyle=0, glinethick=0.5
>
> cgPlotS, [10,30], [30,50], Color='grn7'; Straight line.
>
> cgPlotS, Map_2Points(10, 30, 30, 50, DPath=1, NPath=50), $
>
> Color='red' ; Evenly spaced in distance
>
> cgPlotS, Map_2Points(10, 30, 30, 50, /RHUMB, NPath=50), $
>
> Color='blue' ; Evenly spaced in longitude.
>
> ;device, /close
>
> END
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")


Thanks David, that's just what I was after. I was actually wanting to plot a line with a large change in lat/lon, so the difference between a great circle and straight line is noticeable.

On a similar topic, does anyone know of a method which would allow a circle to be plotted on a globe, from a specification of the central lat/lon location and the radius?

I'm currently looking through the coyote routines and online, but if anyone knows off-hand a way of doing it, please let me know!

Thanks,

Liam
Re: Plot curved line on a globe projection [message #85350 is a reply to message #85349] Sun, 28 July 2013 13:36 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
ljs15@fsmail.net writes:

> On a similar topic, does anyone know of a method which would allow a circle to be plotted on a globe, from a specification of the central lat/lon location and the radius?

In general, the way this would be done is to work in projected meter
space, not lat/lon space. Then, the equation of a circle is trivial. If
you *have* to plot in lat/lon you can inverse transform your circle
points from projected meter space to lat/lon space.

The cgMap object always works in projected meter space. :-)

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Re: Plot curved line on a globe projection [message #85351 is a reply to message #85350] Sun, 28 July 2013 13:45 Go to previous message
Sir Loin Steak is currently offline  Sir Loin Steak
Messages: 42
Registered: January 2012
Member
On Sunday, 28 July 2013 21:36:53 UTC+1, David Fanning wrote:
> ljs15@fsmail.net writes:
>
>
>
>> On a similar topic, does anyone know of a method which would allow a circle to be plotted on a globe, from a specification of the central lat/lon location and the radius?
>
>
>
> In general, the way this would be done is to work in projected meter
>
> space, not lat/lon space. Then, the equation of a circle is trivial. If
>
> you *have* to plot in lat/lon you can inverse transform your circle
>
> points from projected meter space to lat/lon space.
>
>
>
> The cgMap object always works in projected meter space. :-)
>
>
>
> Cheers,
>
>
>
> David
>
>
>
>
>
>
>
> --
>
> David Fanning, Ph.D.
>
> Fanning Software Consulting, Inc.
>
> Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
>
> Sepore ma de ni thue. ("Perhaps thou speakest truth.")


Thanks again David. I'll give that a go.

I thought I'd struck gold with the ellipse function (http://www.exelisvis.com/docs/ELLIPSE.html), but it appears my idl package doesn't know what this is!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: UNsharing an IDLgrImage
Next Topic: Increasing the whitespace between plot axes and the label?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:12:56 PDT 2025

Total time taken to generate the page: 0.01431 seconds