Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ortho projection w/ limits crashes #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mankoff opened this issue Sep 10, 2014 · 7 comments
Open

ortho projection w/ limits crashes #164

mankoff opened this issue Sep 10, 2014 · 7 comments

Comments

@mankoff
Copy link

mankoff commented Sep 10, 2014

Basemap documentation states that ortho projection can take ll/ur crnr limits. The following code seems like it should work (mpl 1.4.0), but does not:

from mpl_toolkits.basemap import Basemap
m = Basemap(projection='ortho',lon_0=0,lat_0=0,llcrnrlat=-10,llcrnrlon=-10,urcrnrlat=10,urcrnrlon=10)

Error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-98fbf042abb9> in <module>()
----> 1 m = Basemap(projection='ortho',lon_0=0,lat_0=0,llcrnrlat=-10,llcrnrlon=-10,urcrnrlat=10,urcrnrlon=10)

/Users/mankoff/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.pyc in __init__(self, llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, llcrnrx, llcrnry, urcrnrx, urcrnry, width, height, projection, resolution, area_thresh, rsphere, ellps, lat_ts, lat_1, lat_2, lat_0, lon_0, lon_1, lon_2, o_lon_p, o_lat_p, k_0, no_rot, suppress_ticks, satellite_height, boundinglat, fix_aspect, anchor, celestial, round, epsg, ax)
   1032         self.area_thresh = area_thresh
   1033         # define map boundary polygon (in lat/lon coordinates)
-> 1034         blons, blats, self._boundarypolyll, self._boundarypolyxy = self._getmapboundary()
   1035         self.boundarylats = blats
   1036         self.boundarylons = blons

/Users/mankoff/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.pyc in _getmapboundary(self)
   1464             # circular region.
   1465             thetas = np.linspace(0.,2.*np.pi,2*nx*ny)[:-1]
-> 1466             rminor = self._height
   1467             rmajor = self._width
   1468             x = rmajor*np.cos(thetas) + rmajor

AttributeError: 'Basemap' object has no attribute '_height'
> /Users/mankoff/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/mpl_toolkits/basemap/__init__.py(1466)_getmapboundary()
   1465             thetas = np.linspace(0.,2.*np.pi,2*nx*ny)[:-1]
-> 1466             rminor = self._height
   1467             rmajor = self._width

ipdb>
@jswhit
Copy link

jswhit commented Sep 10, 2014

you can use lcrnrx,llcrnry,urcrnrx,urcrnry (corners in map projection coords) but not lat/lon.

@mankoff
Copy link
Author

mankoff commented Sep 10, 2014

Ok. Then perhaps consider this a documentation bug. The current docs here: http://matplotlib.org/basemap/api/basemap_api.html state,

For ortho... the lat/lon values of the corners may be specified, or the x/y values of the corners...

@PBrockmann
Copy link

Not sure to understand because indeed without lat_0 and lon_0

from mpl_toolkits.basemap import Basemap
m = Basemap(projection='ortho',llcrnrlat=-10,llcrnrlon=-10,urcrnrlat=10,urcrnrlon=10)

it gives

 ValueError: must specify lat_0 and lon_0 for Orthographic basemap

@mankoff
Copy link
Author

mankoff commented Jan 8, 2015

@PBrockmann I'm not sure what your comment has to do with this bug. With lat_0 and lon_0 specified, it says that corners may be specified in lon/lat coordinates, but that is not correct, they must be in x,y coords. We aren't discussing the presence/absence of the lat_0,lon_0 arguments.

@PBrockmann
Copy link

The "but not lat/lon" from jswhit push me to try without lat_0 and lon_0.
Sorry for the missunderstanding and thank you for the clarification.

@WeatherGod
Copy link
Member

I would like to clean up any documentation bugs soon. Could someone please suggest a revised line? Even better, could someone put together a PR with the documentation correction?

Also, ideally, I would want to produce a better error message in this case, so a suggested error message would be useful, too.

full discloser, I don't work in ortho projections, so I have no clue what is/isn't allowed.

@ImportanceOfBeingErnest
Copy link
Member

Can someone please comment on how to obtain
lcrnrx,llcrnry,urcrnrx,urcrnry given that I have llcrnrlat=-10,llcrnrlon=-10,urcrnrlat=10,urcrnrlon=10?
Usually you may get x,y as x,y = m(lon,lat); however, if you need to know these already when instantiating the Basemap, you cannot use the Basemap to calculate the values to input in its initialisation method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants