Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## matplotlib-users

 [Matplotlib-users] basemap, drawing a greatcircle passing the map borders From: Benyang Tang - 2005-05-27 21:09:46 ```I have a quick hack of basemap to allow it to draw a great circle passing the map borders. It should work for the cylinder project (i.e., no projection) and a map with longitude -180 to 180. Instruction: - Edit the file: PythonInstallDirectory/lib/python2.4/site-packages/matplotlib/toolkits/basemap/basemap.py - Insert the following line x,y = fixlon(x,y) before this line self.plot(x,y,**kwargs) - Add the following to the top of the file: import Numeric as Num import MA def fixlon(lon,lat): if type(lon) == type([1,]) or type(lon) == type((1,)): lon0 = Num.array(lon) lat0 = Num.array(lat) else: lon0 = lon lat0 = lat # n = len(lon0) temp1 = lon0[1:] - lon0[:-1] temp2 = temp1>0 np = Num.sum(temp2) # isIncrease = None if np<=2: isIncrease = 1 elif n-np<=2: isIncrease = 0 else: print 'n, np = ', n, np return # if not isIncrease: temp2 = Num.logical_not(temp2) temp3 = Num.nonzero(temp2) i0 = Num.argmax( Num.take(Num.fabs(temp1), temp3) ) i = temp3[i0] print 'n,i=', n, i # lon1 = MA.array(Num.zeros((n+1,)),mask=Num.zeros((n+1,))).astype(lon0.typecode()) lat1 = MA.array(Num.zeros((n+1,)),mask=Num.zeros((n+1,))).astype(lon0.typecode()) lon1[:i+1] = lon0[:i+1] lat1[:i+1] = lat0[:i+1] lon1[i+2:] = lon0[i+1:] lat1[i+2:] = lat0[i+1:] lon1.mask()[i+1] = 1 lat1.mask()[i+1] = 1 # return lon1, lat1 ```
 Re: [Matplotlib-users] basemap, drawing a greatcircle passing the map borders From: John Hunter - 2005-05-28 03:50:49 ```>>>>> "Benyang" == Benyang Tang writes: Benyang> I have a quick hack of basemap to allow it to draw a Benyang> great circle passing the map borders. It should work for Benyang> the cylinder project (i.e., no projection) and a map with Benyang> longitude -180 to 180. Benyang> Instruction: > - Add the following to the top of the file: > import Numeric as Num > import MA I think basemap requires numarray, presumably because of it's dependence on nd_image, so if I'm not mistaken you example should be rewritten to use numarray versions of the modules above. Eg, import numarray as Num import numarray.ma as MA and so on... JDH ```