In [1]: from mpl_toolkits.basemap import maskoceans In [2]: import sys, os In [3]: import numpy as np In [4]: ny, nx = 360, 720 In [5]: lons = np.linspace(180.0/nx, 360.0-180.0/nx, nx) In [6]: lats = np.linspace(-90.0+90.0/ny, 90.0-90.0/ny, ny) In [7]: lons, lats = np.meshgrid(lons, lats) In [8]: lndmsk = maskoceans(lons, lats, np.ones((ny,nx))) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) /usr/local/src/pyenv/versions/3.6.1/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds) 56 try: ---> 57 return getattr(obj, method)(*args, **kwds) 58 TypeError: 'float' object cannot be interpreted as an integer During handling of the above exception, another exception occurred: TypeError Traceback (most recent call last) <ipython-input-194-c2af19af1be2> in <module> ----> 1 maskoceans(lons, lats, lndmsk) /usr/local/src/pyenv/versions/3.6.1/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py in maskoceans(lonsin, latsin, datain, inlands, resolution, grid) 5105 # read in land/sea mask. 5106 lsmask_lons, lsmask_lats, lsmask =\ -> 5107 _readlsmask(lakes=inlands,resolution=resolution,grid=grid) 5108 # nearest-neighbor interpolation to output grid. 5109 lsmasko = interp(lsmask,lsmask_lons,lsmask_lats,lonsin,latsin,masked=True,order=0) /usr/local/src/pyenv/versions/3.6.1/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py in _readlsmask(lakes, resolution, grid) 5130 gzip.open(os.path.join(basemap_datadir,'lsmask_%smin_%s.bin' %\ 5131 (grid,resolution)), 'rb') -> 5132 lsmask =\ 5133 np.reshape(np.fromstring(lsmaskf.read(),dtype=np.uint8),(nlats,nlons)) 5134 if lakes: /usr/local/src/pyenv/versions/3.6.1/lib/python3.6/site-packages/numpy/core/fromnumeric.py in reshape(a, newshape, order) 230 [5, 6]]) 231 """ --> 232 return _wrapfunc(a, 'reshape', newshape, order=order) 233 234 /usr/local/src/pyenv/versions/3.6.1/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds) 65 # a downstream library like 'pandas'. 66 except (AttributeError, TypeError): ---> 67 return _wrapit(obj, method, *args, **kwds) 68 69 /usr/local/src/pyenv/versions/3.6.1/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds) 45 except AttributeError: 46 wrap = None ---> 47 result = getattr(asarray(obj), method)(*args, **kwds) 48 if wrap: 49 if not isinstance(result, mu.ndarray): TypeError: 'float' object cannot be interpreted as an integer