@@ -2889,10 +2889,6 @@ def drawgreatcircle(self,lon1,lat1,lon2,lat2,del_s=100.,**kwargs):
2889
2889
method of Basemap instance.
2890
2890
============== =======================================================
2891
2891
2892
- .. note::
2893
- Cannot handle situations in which the great circle intersects
2894
- the edge of the map projection domain, and then re-enters the domain.
2895
-
2896
2892
Returns a matplotlib.lines.Line2D object.
2897
2893
"""
2898
2894
# use great circle formula for a perfect sphere.
@@ -2906,7 +2902,34 @@ def drawgreatcircle(self,lon1,lat1,lon2,lat2,del_s=100.,**kwargs):
2906
2902
lats .append (lat )
2907
2903
lons .append (lon2 ); lats .append (lat2 )
2908
2904
x , y = self (lons , lats )
2909
- return self .plot (x ,y ,** kwargs )
2905
+
2906
+ # Correct wrap around effect of great circles
2907
+
2908
+ # get points
2909
+ p = self .plot (x ,y ,** kwargs )[0 ].get_path ()
2910
+
2911
+ # since we know the difference between any two points, we can use this to find wrap arounds on the plot
2912
+ max_dist = 1000 * del_s * 2
2913
+
2914
+ # calculate distances and compare with max allowable distance
2915
+ dists = np .abs (np .diff (p .vertices [:,0 ]))
2916
+ cuts = np .where ( dists > max_dist )[0 ]
2917
+
2918
+ # if there are any cut points, cut them and begin again at the next point
2919
+ for i ,k in enumerate (cuts ):
2920
+ # vertex to cut at
2921
+ cut_point = cuts [i ]
2922
+
2923
+ # create new vertices with a nan inbetween and set those as the path's vertices
2924
+ verts = np .concatenate (
2925
+ [p .vertices [:cut_point , :],
2926
+ [[np .nan , np .nan ]],
2927
+ p .vertices [cut_point + 1 :, :]]
2928
+ )
2929
+ p .codes = None
2930
+ p .vertices = verts
2931
+
2932
+ return p
2910
2933
2911
2934
def transform_scalar (self ,datin ,lons ,lats ,nx ,ny ,returnxy = False ,checkbounds = False ,order = 1 ,masked = False ):
2912
2935
"""
@@ -4056,10 +4079,16 @@ def warpimage(self,image="bluemarble",scale=None,**kwargs):
4056
4079
4057
4080
returns a matplotlib.image.AxesImage instance.
4058
4081
"""
4082
+
4083
+ # fix PIL import on some versions of OSX and scipy
4059
4084
try :
4060
4085
from PIL import Image
4061
4086
except ImportError :
4062
- raise ImportError ('warpimage method requires PIL (http://www.pythonware.com/products/pil)' )
4087
+ try :
4088
+ import Image
4089
+ except ImportError :
4090
+ raise ImportError ('warpimage method requires PIL (http://www.pythonware.com/products/pil)' )
4091
+
4063
4092
from matplotlib .image import pil_to_array
4064
4093
if self .celestial :
4065
4094
msg = 'warpimage does not work in celestial coordinates'
0 commit comments