trvrrp
trvrrp

Reputation: 554

Matplotlib Basemap example code fails due to MemoryError

I'm trying to use the Basemap toolkit from matplotlib to plot data on a map. When I try to run the following code

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
# setup Lambert Conformal basemap.
# set resolution=None to skip processing of boundary datasets.
m = Basemap(width=12000000,height=9000000,projection='lcc',
            resolution=None,lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
m.shadedrelief()
plt.show()

which is copied and pasted directly from example #4 on the basemap tutorial

The code fails with this error:

Traceback (most recent call last):
  File "basemap_test.py", line 11, in <module>
    m.shadedrelief()
  File "C:\Python35-32\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 4043, in shadedrelief
    return self.warpimage(image='shadedrelief',scale=scale,**kwargs)
  File "C:\Python35-32\lib\site-packages\mpl_toolkits\basemap\__init__.py", line 4171, in warpimage
    self._bm_rgba = self._bm_rgba.astype(np.float32)/255.
MemoryError

I am running Python 3.5.1 using matplotlib version 1.5.1 and Basemap version 1.0.8

I have found a couple threads (here and here) that deal with similar bugs in mpl_toolkits/basemap/init.py that have supposedly been fixed but none that address this problem.

Any help would be appreciated!

Upvotes: 1

Views: 458

Answers (1)

trvrrp
trvrrp

Reputation: 554

Solved the issue by upgrading to 64-bit python. It seems that even though Basemap publishes a version for 32-bit python not all the map functions work in 32-bit, even the standard examples.

Upvotes: 1

Related Questions