Suggestion for zooming (orthographic projection)

Hi,

Trying the code at
http://matplotlib.sourceforge.net/basemap/doc/html/users/ortho.html ,
for zooming in a certain region on a globe, I have found some issues
with the approach provided.
For example, it does not work on the poles.
Here is my suggestion for a zoom with a factor = coef.

···

#########################################################################

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
# global ortho map centered on lon_0,lat_0
lat_0=90.; lon_0=0.
# resolution = None means don't process the boundary datasets.
m1 = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)

width = m1.urcrnrx - m1.llcrnrx
height = m1.urcrnry - m1.llcrnry

coef = 0.5
width = width*coef
height = height*coef
m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l',\
   llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)

m.drawcoastlines()
m.drawcountries()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
m.drawmapboundary()
plt.show()

Alexis:

This is now fixed in github master (https://github.com/matplotlib/basemap).

-Jeff

···

On 1/19/12 10:02 AM, Alexis Praga wrote:

Hi,

Trying the code at
http://matplotlib.sourceforge.net/basemap/doc/html/users/ortho.html ,
for zooming in a certain region on a globe, I have found some issues
with the approach provided.
For example, it does not work on the poles.
Here is my suggestion for a zoom with a factor = coef.

#########################################################################

from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
# global ortho map centered on lon_0,lat_0
lat_0=90.; lon_0=0.
# resolution = None means don't process the boundary datasets.
m1 = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)

width = m1.urcrnrx - m1.llcrnrx
height = m1.urcrnry - m1.llcrnry

coef = 0.5
width = width*coef
height = height*coef
m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l',\
    llcrnrx=-0.5*width,llcrnry=-0.5*height,urcrnrx=0.5*width,urcrnry=0.5*height)

m.drawcoastlines()
m.drawcountries()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
m.drawmapboundary()
plt.show()

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg