Skip to content

Commit 54fd9f1

Browse files
author
Henry Hammond
committed
Merge branch 'master' of github.com:HHammond/basemap
2 parents c0c5667 + 45b4287 commit 54fd9f1

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

examples/nytolondon.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
# lonlat, lonlon are lat/lon of London.
1818
lonlat = 51.53
1919
lonlon = 0.08
20+
2021
# find 1000 points along the great circle.
2122
#x,y = m.gcpoints(nylon,nylat,lonlon,lonlat,1000)
2223
# draw the great circle.
2324
#m.plot(x,y,linewidth=2)
2425
# drawgreatcircle performs the previous 2 steps in one call.
2526
m.drawgreatcircle(nylon,nylat,lonlon,lonlat,linewidth=2,color='b')
27+
2628
m.drawcoastlines()
2729
m.fillcontinents()
2830
# draw parallels
@@ -46,6 +48,7 @@
4648
# lonlat, lonlon are lat/lon of London.
4749
lonlat = 51.53
4850
lonlon = 0.08
51+
4952
# find 1000 points along the great circle.
5053
#x,y = m.gcpoints(nylon,nylat,lonlon,lonlat,1000)
5154
# draw the great circle.
@@ -63,3 +66,55 @@
6366
plt.title('Great Circle from New York to London (Gnomonic)')
6467
sys.stdout.write('plotting Great Circle from New York to London (Gnomonic)\n')
6568
plt.show()
69+
70+
71+
# Example of Great Circles which exit and reenter the map
72+
m = Basemap(projection='robin', lat_0=0, lon_0=0,resolution='c')
73+
74+
m.drawmapboundary(fill_color='#ffffff',color='#ffffff')
75+
m.fillcontinents(color='#f2f2f2',lake_color='#ffffff')
76+
m.drawcoastlines(color='#e0e0e0')
77+
m.drawcountries(color='#e0e0e0')
78+
79+
parallels = np.arange(-90,90,10.)
80+
meridians = np.arange(10.,351.,20.)
81+
m.drawparallels(parallels,labels=[False,False,False,False], color='#d3d3d3',dashes=[1,3])
82+
m.drawmeridians(meridians,labels=[False,False,False,False], color='#d3d3d3',dashes=[1,3])
83+
84+
# Choose the lat and longtitude of two points
85+
86+
p1 = (45.27,-75.42) # roughly Ottawa
87+
p2 = (44.05,-4.28) # roughly Paris
88+
p3 = (-38.58,145.05) # roughly Victoria
89+
90+
la1, lo1 = p1
91+
la2, lo2 = p2
92+
la3, lo3 = p3
93+
94+
# Drawing points; you need to convert from lon-lat to xy-cartesian
95+
x1,y1 = m(lo1,la1)
96+
x2,y2 = m(lo2,la2)
97+
x3,y3 = m(lo3,la3)
98+
99+
# Convert back by setting inverse=True
100+
lon,lat = m(x1,y1,inverse=True)
101+
102+
# Plot pionts using markers
103+
m.plot(x1,y1, marker='.', markersize=8, color='#000000')
104+
m.plot(x2,y2, marker='.', markersize=8, color='#000000')
105+
m.plot(x3,y3, marker='.', markersize=8, color='#000000')
106+
107+
# Of note, the map uses metres as it's smallest distance, so 1000*x is x km
108+
# The offset is in projection cooordinates
109+
plt.text(x1+100000,y1+100000,'Ottawa')
110+
plt.text(x2+100000,y2+100000,'Paris')
111+
plt.text(x3+100000,y3+100000,'Victoria')
112+
113+
# Draw a great circle line joining them
114+
m.drawgreatcircle(lo1,la1,lo2,la2,linewidth=1,color='#000000',alpha=1,del_s=100)
115+
m.drawgreatcircle(lo2,la2,lo3,la3,linewidth=1,color='#000000',alpha=1,del_s=100)
116+
117+
# Drawing a great circle which exits and reenters the map works on certain projections
118+
m.drawgreatcircle(lo1,la1,lo3,la3,linewidth=1,color='#FF0000',alpha=1,del_s=100)
119+
120+
plt.show()

0 commit comments

Comments
 (0)