Skip to content

Commit 77aaa7a

Browse files
Add gallery example showing usage of project (#1696)
* Create gallery example showing the usage of project Co-authored-by: Dongdong Tian <[email protected]>
1 parent 6e70e8b commit 77aaa7a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
Generate points along great circles
3+
-----------------------------------
4+
5+
The :meth:`pygmt.project` method can generate points along a great circle
6+
whose center and end points can be defined via the ``center`` and ``endpoint``
7+
parameters, respectively. Using the ``generate`` parameter allows to generate
8+
(*r*, *s*, *p*) points every *dist* units of *p* along a profile as
9+
output. By default all units (*r*, *s* and *p*) are set to degrees while
10+
``unit=True`` allows to set the unit for *p* to km.
11+
"""
12+
13+
import pygmt
14+
15+
fig = pygmt.Figure()
16+
17+
# generate points every 10 degrees along a great circle from 10N,50W to 30N,5W
18+
points1 = pygmt.project(center=[-50, 10], endpoint=[-5, 30], generate=10)
19+
# generate points every 750 km along a great circle from 10N,50W to 57.5N,90W
20+
points2 = pygmt.project(center=[-50, 10], endpoint=[-90, 57.5], generate=750, unit=True)
21+
# generate points every 350 km along a great circle from 10N,50W to 68N,5W
22+
points3 = pygmt.project(center=[-50, 10], endpoint=[-5, 68], generate=350, unit=True)
23+
24+
# create a plot with coast and Mercator projection (M)
25+
fig.basemap(region=[-100, 0, 0, 70], projection="M12c", frame=True)
26+
fig.coast(shorelines=True, area_thresh=5000)
27+
28+
# plot individual points of first great circle as seagreen line
29+
fig.plot(x=points1.r, y=points1.s, pen="2p,seagreen")
30+
# plot individual points as seagreen squares atop
31+
fig.plot(x=points1.r, y=points1.s, style="s.45c", color="seagreen", pen="1p")
32+
33+
# plot individual points of second great circle as orange line
34+
fig.plot(x=points2.r, y=points2.s, pen="2p,orange")
35+
# plot individual points as orange inverted triangles atop
36+
fig.plot(x=points2.r, y=points2.s, style="i.6c", color="orange", pen="1p")
37+
38+
# plot individual points of third great circle as red line
39+
fig.plot(x=points3.r, y=points3.s, pen="2p,red3")
40+
# plot individual points as red circles atop
41+
fig.plot(x=points3.r, y=points3.s, style="c.3c", color="red3", pen="1p")
42+
43+
fig.show()

0 commit comments

Comments
 (0)