...
 
Commits (9)
......@@ -67,3 +67,5 @@ doc/examples
doc/_templates/gallery.html
doc/users/installing.rst
doc/_static/matplotlibrc
.DS_Store
......@@ -12,7 +12,7 @@ env:
addons:
apt:
packages:
- libgeos-3.3.8
- libgeos-3.4.2
# matplotlib requirements
- libpng12-dev
- libfreetype6-dev
......
version 1.2.0
-------------
* Mostly compatibility bugfixes
version 1.1.0 (git tag v1.1.0rel)
--------------------------------
* Updated packaged data to use GSHHG v2.3.6 (PR #311 & #320)
......
#Basemap
# Basemap
Plot on map projections (with coastlines and political boundaries)
using matplotlib.
##Requirements
## Requirements
* Python 2.6 (or higher)
......@@ -23,7 +23,7 @@ sure the corresponding "python-dev" package is also installed. Otherwise, you
may not have the python header (Python.h), which is required to build python
C extensions.
###Optional
### Optional
* [OWSLib](https://github.com/geopython/OWSLib) (optional) It is needed
for the BaseMap.wmsimage function.
......@@ -32,7 +32,7 @@ for the BaseMap.wmsimage function.
needed for Basemap warpimage, bluemarble, shadedrelief, and etop methods.
PIL should work on Python 2.x. Pillow is a maintained fork of PIL.
##Copyright
## Copyright
source code for the GEOS library is
included in the 'geos-3.3.3' directory under the terms given in
......@@ -59,7 +59,7 @@ USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
##Documentation
## Documentation
see http://matplotlib.github.com/basemap/
......@@ -68,7 +68,7 @@ see scripts in 'examples' directory for example usage.
read the FAQ and/or email the matplotlib-users mailing list if
you have problems or questions.
##Install
## Install
0. Install pre-requisite python modules numpy and matplotlib.
......@@ -100,10 +100,10 @@ prompt.
To run all the examples (except those that have extra dependencies
or require an internet connection), execute 'python run_all.py'.
##Contact
## Contact
Ben Root <ben.v.root@gmail.com>
##Thanks
## Thanks
Special thanks to John Hunter, Andrew Straw, Eric Firing, Rob Hetland, Scott Sinclair, Ivan Lima, Erik Andersen, Michael Hearne, Jesper Larsen, Ryan May, David Huard, Mauro Cavalcanti, Jonas Bluethgen, Chris Murphy, Pierre Gerard-Marchant, Christoph Gohlke, Eric Bruning, Stephane Raynaud, Tom Loredo, Patrick Marsh, Phil Elson, and Henry Hammond for valuable contributions.
basemap (1.2.0+dfsg-1) unstable; urgency=medium
* New upstream release; Closes: #918643
* debian/watch
- match tags with `rel` suffix
* debian/copyright
- extend packaging copyright years
* debian/patches/*
- refresh patches
* debian/control
- add setuptool, six, pyshp, pyproj, matplotlib, netcdf4 to b-d
- bump Standards-Version to 4.3.0 (no changes needed)
* debian/control
- rework for new upstream setup.py
-- Sandro Tosi <morph@debian.org> Thu, 10 Jan 2019 17:53:21 -0500
basemap (1.1.0+dfsg-3) unstable; urgency=medium
[ Ondřej Nový ]
......
......@@ -15,11 +15,15 @@ Build-Depends:
python-dap,
python-httplib2,
python-matplotlib,
python3-matplotlib,
python-netcdf4,
python3-netcdf4,
python-numpy (>= 1:1.5.1-4),
python-numpy-dbg,
python-pyproj,
python3-pyproj,
python-pyshp,
python3-pyshp,
python-sphinx (>= 1.0.7+dfsg),
python-tk,
python3-all,
......@@ -27,7 +31,11 @@ Build-Depends:
python3-all-dev,
python3-numpy,
python3-numpy-dbg,
Standards-Version: 4.2.1
python-setuptools,
python3-setuptools,
python-six,
python3-six,
Standards-Version: 4.3.0
Homepage: http://matplotlib.org/basemap/
Vcs-Git: https://salsa.debian.org/python-team/modules/basemap.git
Vcs-Browser: https://salsa.debian.org/python-team/modules/basemap
......
......@@ -20,7 +20,7 @@ License: MIT
PERFORMANCE OF THIS SOFTWARE.
Files: debian/*
Copyright: 2011-2018 Sandro Tosi <morph@debian.org>
Copyright: 2011-2019 Sandro Tosi <morph@debian.org>
License: same as upstream
Files: doc/*
......
......@@ -10,13 +10,11 @@ Patch-Name: dont_install_data_files
setup.py | 1 -
1 file changed, 1 deletion(-)
diff --git a/setup.py b/setup.py
index 3b23b58..6b2012b 100644
--- a/setup.py
+++ b/setup.py
@@ -148,5 +148,4 @@ setup(
namespace_packages = namespace_packages,
package_dir = package_dirs,
ext_modules = extensions,
cmdclass = {'build_py': build_py},
ext_modules = extensions,
- package_data = package_data
)
......@@ -9,11 +9,9 @@ Patch-Name: use_share_datafiles
lib/mpl_toolkits/basemap/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/mpl_toolkits/basemap/__init__.py b/lib/mpl_toolkits/basemap/__init__.py
index 10fb6d0..535022b 100644
--- a/lib/mpl_toolkits/basemap/__init__.py
+++ b/lib/mpl_toolkits/basemap/__init__.py
@@ -47,7 +47,7 @@ if 'BASEMAPDATA' in os.environ:
@@ -56,7 +56,7 @@ if 'BASEMAPDATA' in os.environ:
if not os.path.isdir(basemap_datadir):
raise RuntimeError('Path in environment BASEMAPDATA not a directory')
else:
......
......@@ -11,28 +11,17 @@ override_dh_auto_install:
set -e ; \
cython3 -2 src/*pyx; \
for python in $(PY2VERS); do \
$$python setup.py install --prefix $(CURDIR)/debian/python-mpltoolkits.basemap/usr --install-layout=deb; \
$$python-dbg setup.py install --prefix $(CURDIR)/debian/python-mpltoolkits.basemap-dbg/usr --install-layout=deb; \
$$python setup.py install --root $(CURDIR)/debian/python-mpltoolkits.basemap/ --install-layout=deb; \
$$python-dbg setup.py install --root $(CURDIR)/debian/python-mpltoolkits.basemap-dbg/ --install-layout=deb; \
done
set -e ; \
cython3 -3 src/*pyx; \
for python in $(PY3VERS); do \
$$python setup.py install --prefix $(CURDIR)/debian/python3-mpltoolkits.basemap/usr --install-layout=deb; \
$$python-dbg setup.py install --prefix $(CURDIR)/debian/python3-mpltoolkits.basemap-dbg/usr --install-layout=deb; \
$$python setup.py install --root $(CURDIR)/debian/python3-mpltoolkits.basemap/ --install-layout=deb; \
$$python-dbg setup.py install --root $(CURDIR)/debian/python3-mpltoolkits.basemap-dbg/ --install-layout=deb; \
done
dh_numpy
override_dh_python2:
dh_python2
# remove namespace file, already shipped with python-matplotlib
rm $(CURDIR)/debian/python-mpltoolkits.basemap/usr/lib/python2*/dist-packages/mpl_toolkits/__init__.py
override_dh_python3:
dh_python3
# remove namespace file, already shipped with python3-matplotlib
rm $(CURDIR)/debian/python3-mpltoolkits.basemap/usr/lib/python3*/dist-packages/mpl_toolkits/__init__.py
build: build-arch build-indep ;
build-arch:
......
version=4
opts="dversionmangle=s/\+dfsg//,filenamemangle=s%(?:.*?)?v?(\d[\d.]*)\.tar\.gz%basemap-$1.tar.gz%,repacksuffix=+dfsg" \
https://github.com/matplotlib/basemap/tags (?:.*?/)?v?(\d[\d.]*)\.tar\.gz
opts="dversionmangle=s/\+dfsg//,filenamemangle=s%(?:.*?)?v?(\d[\d.]*)(?:rel)?\.tar\.gz%basemap-$1.tar.gz%,repacksuffix=+dfsg" \
https://github.com/matplotlib/basemap/tags (?:.*?/)?v?(\d[\d.]*)(?:rel)?\.tar\.gz
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
# setup north polar stereographic basemap.
# setup south polar stereographic basemap.
# The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge
# of the map at lon_0. Default value of lat_ts
......
......@@ -10,23 +10,24 @@ Dependencies
**Requirements**
These are external packages which you will need to install before
installing basemap.
installing Basemap.
matplotlib 1.0.0 (or later, `download <http://sf.net/projects/matplotlib/>`__)
Matplotlib 1.0.0 (or later, `download <https://matplotlib.org/users/installing.html>`__)
Python 2.4 (or later, including Python 3)
matplotlib requires python 2.4 or later (`download <http://www.python.org/download/>`__)
Python 2.6 (or later, including Python 3) (`download <http://www.python.org/download/>`__)
Matplotlib 2.2 LTS requires Python 2.7 or later
Matplotlib 3.0 requires Python 3.5 or later
numpy 1.2.1 (or later)
array support for python (`download <http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__)
NumPy 1.2.1 (or later)
Array support for Python (`download <http://www.numpy.org/>`__)
`PROJ4 <https://trac.osgeo.org/proj/>`__ Cartographic Projections Library.
**Required library that ships with basemap**
**Required library that ships with Basemap**
`GEOS <http://trac.osgeo.org/geos/>`__ (Geometry Engine - Open Source) library 3.1.1 or later.
Source code is included in the geos-3.3.3 directory.
Source code is included in the geos-3.3.3 directory.
When building from source, must be built and installed separately
from basemap (see build instructions below).
Included in Windows binary installers.
......@@ -40,8 +41,8 @@ Pillow
Installation
============
Download either Windows binary installers or source tarballs
`here <https://github.com/matplotlib/basemap/releases/>`__.
Download either Windows binary installers or source tarballs
`here <https://github.com/matplotlib/basemap/releases/>`__.
To install from the source, follow these steps:
......@@ -52,7 +53,7 @@ To install from the source, follow these steps:
and cd to the basemap-X.Y.Z directory.
* Install the GEOS library. If you already have it on your
system, just set the environment variable GEOS_DIR to point to the location
system, just set the environment variable GEOS_DIR to point to the location
of libgeos_c and geos_c.h (if libgeos_c is in /usr/local/lib and
geos_c.h is in /usr/local/include, set GEOS_DIR to /usr/local).
Then go to next step. If you don't have it, you can build it from
......@@ -62,12 +63,12 @@ To install from the source, follow these steps:
export GEOS_DIR=<where you want the libs and headers to go>
# A reasonable choice on a Unix-like system is /usr/local, or
# if you don't have permission to write there, your home directory.
./configure --prefix=$GEOS_DIR
./configure --prefix=$GEOS_DIR
make; make install
* cd back to the top level basemap directory (basemap-X.Y.Z) and
run the usual ``python setup.py install``. Check your installation
by running ``from mpl_toolkits.basemap import Basemap`` at the python
by running ``from mpl_toolkits.basemap import Basemap`` at the Python
prompt.
* To test, cd to the examples directory and run ``python simpletest.py``.
......
from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals
"""
AllSkyMap is a subclass of Basemap, specialized for handling common plotting
......
from __future__ import (absolute_import, division, print_function)
"""
Example of astronomical use of AllSkyMap class in allskymap.py module
......
from __future__ import (absolute_import, division, print_function)
# example using matplotlib.animation to create a movie
# reads data over http - needs an active internet connection.
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
"""
This example shows how to plot data on rectangular 2D grids
(grids that are not rectlinear in geographic or native map projection
......@@ -56,7 +58,7 @@ m.drawcoastlines()
m.fillcontinents(color='white')
x, y = m(tlon,tlat)
im = m.pcolor(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),
im = m.pcolormesh(x,y,ma.masked_array(np.zeros(temp.shape,'f'), temp.mask),
shading='faceted', antialiased=True, cmap=plt.cm.cool,
vmin=0, vmax=0)
# disclaimer: these are not really the grid cells because of the
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
def draw_map_background(m, ax):
ax.set_axis_bgcolor('#729FCF')
ax.set_facecolor('#729FCF')
m.fillcontinents(color='#FAFAFA', ax=ax, zorder=0)
m.drawcounties(ax=ax)
m.drawstates(ax=ax)
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
......
from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals
from mpl_toolkits.basemap import Basemap
import numpy as np
......
from __future__ import (absolute_import, division, print_function)
import numpy as np
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
#!/usr/bin/env python
"""
An example of how to use wx or wxagg in an application with the Basemap module
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals
# this example reads today's numerical weather forecasts
# from the NOAA OpenDAP servers and makes a multi-panel plot.
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
from __future__ import unicode_literals
# this example reads today's numerical weather forecasts
# from the NOAA OpenDAP servers and makes a multi-panel plot.
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap as Basemap
from matplotlib.colors import rgb2hex
from matplotlib.colors import rgb2hex, Normalize
from matplotlib.patches import Polygon
from matplotlib.colorbar import ColorbarBase
fig, ax = plt.subplots()
# Lambert Conformal map of lower 48 states.
m = Basemap(llcrnrlon=-119,llcrnrlat=22,urcrnrlon=-64,urcrnrlat=49,
m = Basemap(llcrnrlon=-119,llcrnrlat=20,urcrnrlon=-64,urcrnrlat=49,
projection='lcc',lat_1=33,lat_2=45,lon_0=-95)
# draw state boundaries.
# data from U.S Census Bureau
# http://www.census.gov/geo/www/cob/st2000.html
shp_info = m.readshapefile('st99_d00','states',drawbounds=True)
# population density by state from
# http://en.wikipedia.org/wiki/List_of_U.S._states_by_population_density
# Mercator projection, for Alaska and Hawaii
m_ = Basemap(llcrnrlon=-190,llcrnrlat=20,urcrnrlon=-143,urcrnrlat=46,
projection='merc',lat_ts=20) # do not change these numbers
#%% --------- draw state boundaries ----------------------------------------
## data from U.S Census Bureau
## http://www.census.gov/geo/www/cob/st2000.html
shp_info = m.readshapefile('st99_d00','states',drawbounds=True,
linewidth=0.45,color='gray')
shp_info_ = m_.readshapefile('st99_d00','states',drawbounds=False)
## population density by state from
## http://en.wikipedia.org/wiki/List_of_U.S._states_by_population_density
popdensity = {
'New Jersey': 438.00,
'Rhode Island': 387.35,
......@@ -65,13 +77,13 @@ popdensity = {
'Montana': 2.39,
'Wyoming': 1.96,
'Alaska': 0.42}
print(shp_info)
# choose a color for each state based on population density.
#%% -------- choose a color for each state based on population density. -------
colors={}
statenames=[]
cmap = plt.cm.hot # use 'hot' colormap
cmap = plt.cm.hot_r # use 'reversed hot' colormap
vmin = 0; vmax = 450 # set range.
print(m.states_info[0].keys())
norm = Normalize(vmin=vmin, vmax=vmax)
for shapedict in m.states_info:
statename = shapedict['NAME']
# skip DC and Puerto Rico.
......@@ -80,18 +92,51 @@ for shapedict in m.states_info:
# calling colormap with value between 0 and 1 returns
# rgba value. Invert color range (hot colors are high
# population), take sqrt root to spread out colors more.
colors[statename] = cmap(1.-np.sqrt((pop-vmin)/(vmax-vmin)))[:3]
colors[statename] = cmap(np.sqrt((pop-vmin)/(vmax-vmin)))[:3]
statenames.append(statename)
# cycle through state names, color each one.
ax = plt.gca() # get current axes instance
#%% --------- cycle through state names, color each one. --------------------
for nshape,seg in enumerate(m.states):
# skip DC and Puerto Rico.
if statenames[nshape] not in ['District of Columbia','Puerto Rico']:
color = rgb2hex(colors[statenames[nshape]])
if statenames[nshape] not in ['Puerto Rico', 'District of Columbia']:
color = rgb2hex(colors[statenames[nshape]])
poly = Polygon(seg,facecolor=color,edgecolor=color)
ax.add_patch(poly)
# draw meridians and parallels.
m.drawparallels(np.arange(25,65,20),labels=[1,0,0,0])
m.drawmeridians(np.arange(-120,-40,20),labels=[0,0,0,1])
plt.title('Filling State Polygons by Population Density')
AREA_1 = 0.005 # exclude small Hawaiian islands that are smaller than AREA_1
AREA_2 = AREA_1 * 30.0 # exclude Alaskan islands that are smaller than AREA_2
AK_SCALE = 0.19 # scale down Alaska to show as a map inset
HI_OFFSET_X = -1900000 # X coordinate offset amount to move Hawaii "beneath" Texas
HI_OFFSET_Y = 250000 # similar to above: Y offset for Hawaii
AK_OFFSET_X = -250000 # X offset for Alaska (These four values are obtained
AK_OFFSET_Y = -750000 # via manual trial and error, thus changing them is not recommended.)
for nshape, shapedict in enumerate(m_.states_info): # plot Alaska and Hawaii as map insets
if shapedict['NAME'] in ['Alaska', 'Hawaii']:
seg = m_.states[int(shapedict['SHAPENUM'] - 1)]
if shapedict['NAME'] == 'Hawaii' and float(shapedict['AREA']) > AREA_1:
seg = [(x + HI_OFFSET_X, y + HI_OFFSET_Y) for x, y in seg]
color = rgb2hex(colors[statenames[nshape]])
elif shapedict['NAME'] == 'Alaska' and float(shapedict['AREA']) > AREA_2:
seg = [(x*AK_SCALE + AK_OFFSET_X, y*AK_SCALE + AK_OFFSET_Y)\
for x, y in seg]
color = rgb2hex(colors[statenames[nshape]])
poly = Polygon(seg, facecolor=color, edgecolor='gray', linewidth=.45)
ax.add_patch(poly)
ax.set_title('United states population density by state')
#%% --------- Plot bounding boxes for Alaska and Hawaii insets --------------
light_gray = [0.8]*3 # define light gray color RGB
x1,y1 = m_([-190,-183,-180,-180,-175,-171,-171],[29,29,26,26,26,22,20])
x2,y2 = m_([-180,-180,-177],[26,23,20]) # these numbers are fine-tuned manually
m_.plot(x1,y1,color=light_gray,linewidth=0.8) # do not change them drastically
m_.plot(x2,y2,color=light_gray,linewidth=0.8)
#%% --------- Show color bar ---------------------------------------
ax_c = fig.add_axes([0.9, 0.1, 0.03, 0.8])
cb = ColorbarBase(ax_c,cmap=cmap,norm=norm,orientation='vertical',
label=r'[population per $\mathregular{km^2}$]')
plt.show()
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
"""geos_demo_2.py
This script shows how to plot data onto the Geostationary Satellite projection
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......@@ -6,7 +8,7 @@ fig = plt.figure()
lon_0=57
# global geos map
m1 = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution=None)
ax = fig.add_axes([0.1,0.1,0.8,0.8],axisbg='k')
ax = fig.add_axes([0.1,0.1,0.8,0.8], facecolor='k')
# plot just upper right quadrant (coordinates determined from global map).
m = Basemap(projection='geos',lon_0=lon_0,rsphere=(6378137.00,6356752.3142),resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.)
m.drawcoastlines()
......@@ -22,7 +24,7 @@ fig = plt.figure()
# global ortho map
lat_0=10.
m1 = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution=None)
ax = fig.add_axes([0.1,0.1,0.8,0.8],axisbg='k')
ax = fig.add_axes([0.1,0.1,0.8,0.8], facecolor='k')
# plot just upper right quadrant (corners determined from global map).
m = Basemap(projection='ortho',lon_0=lon_0,lat_0=lat_0,resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.)
m.drawcoastlines()
......
from __future__ import (absolute_import, division, print_function)
# example showing how to plot scattered data with hexbin.
from numpy.random import uniform
import matplotlib.pyplot as plt
......@@ -54,7 +56,7 @@ H, xedges, yedges = np.histogram2d(x, y, bins=bins, weights=z)
H = np.ma.masked_where(mask, H/bincount)
# set color of masked values to axes background (hexbin does this by default)
palette = plt.cm.jet
palette.set_bad(ax.get_axis_bgcolor(), 1.0)
palette.set_bad(ax.get_facecolor(), 1.0)
CS = m.pcolormesh(xedges,yedges,H.T,shading='flat',cmap=palette)
# draw coastlines, lat/lon lines.
m.drawcoastlines()
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
"""
draw Atlantic Hurricane Tracks for storms that reached Cat 4 or 5.
part of the track for which storm is cat 4 or 5 is shown red.
......
from __future__ import (absolute_import, division, print_function)
# example showing how to use Line Integral Convolution to visualize a vector
# flow field (from Hurricane Earl). Produces something akin to streamlines.
# Requires vectorplot scikit (http://scikits.appspot.com/vectorplot).
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap, shiftgrid, maskoceans, interp
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......@@ -32,7 +34,7 @@ plt.title('Near-Sided Perspective Map Centered on Lon=%s, Lat=%s, H=%g' %\
fig = plt.figure()
m1 = Basemap(projection='nsper',lon_0=lon_0,lat_0=lat_0,satellite_height=h,resolution=None)
ax = fig.add_axes([0.1,0.1,0.8,0.8],axisbg='k')
ax = fig.add_axes([0.1,0.1,0.8,0.8], facecolor='k')
# plot just upper right quadrant (coordinates determined from global map).
m = Basemap(projection='nsper',lon_0=lon_0,lat_0=lat_0,satellite_height=h,resolution='l',llcrnrx=0.,llcrnry=0.,urcrnrx=m1.urcrnrx/2.,urcrnry=m1.urcrnry/2.)
m.drawcoastlines()
......
from __future__ import (absolute_import, division, print_function)
# example demonstrating how to draw a great circle on a map.
from mpl_toolkits.basemap import Basemap
import numpy as np
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
from matplotlib import rcParams
from matplotlib.ticker import MultipleLocator
......
from __future__ import (absolute_import, division, print_function)
import numpy as np
import sys
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from matplotlib.mlab import prctile_rank
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap as Basemap
......
from __future__ import (absolute_import, division, print_function)
"""
plot H's and L's on a sea-level pressure map
(uses scipy.ndimage.filters and netcdf4-python)
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
......
from __future__ import (absolute_import, division, print_function)
# make plot of etopo bathymetry/topography data on
# lambert conformal conic map projection, drawing coastlines, state and
# country boundaries, and parallels/meridians.
......
from __future__ import (absolute_import, division, print_function)
# make plot of etopo bathymetry/topography data on
# lambert conformal conic map projection, drawing coastlines, state and
# country boundaries, and parallels/meridians.
......
from __future__ import (absolute_import, division, print_function)
# make plot of etopo bathymetry/topography data on
# lambert conformal conic map projection, drawing coastlines, state and
# country boundaries, and parallels/meridians.
......
from __future__ import (absolute_import, division, print_function)
# make shaded relief plot of etopo bathymetry/topography data on
# lambert conformal conic map projection.
......
from __future__ import (absolute_import, division, print_function)
# make plot of ozone concentration data on
# lambert conformal conic map projection, drawing coastlines, state and
# country boundaries, and parallels/meridians.
......@@ -48,7 +50,7 @@ fig=plt.figure(figsize=(8,8))
# add an axes.
ax = fig.add_axes([0.1,0.1,0.8,0.8])
ax.set_axis_bgcolor('lightgrey')
ax.set_facecolor('lightgrey')
# associate this axes with the Basemap instance.
m.ax = ax
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap, cm
from netCDF4 import Dataset as NetCDFFile
import numpy as np
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
from netCDF4 import Dataset, date2index
import numpy as np
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
# make plots of etopo bathymetry/topography data on
# various map projections, drawing coastlines, state and
# country boundaries, filling continents and drawing
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import rgb2hex
......
from __future__ import (absolute_import, division, print_function)
import glob, os, sys
test_files = glob.glob('*.py')
test_files.remove('run_all.py')
......
from __future__ import (absolute_import, division, print_function)
import matplotlib, sys
matplotlib.use('Agg')
from mpl_toolkits.basemap import Basemap
......
from __future__ import (absolute_import, division, print_function)
# examples of using the 'width' and 'height' keywords
# to the Basemap constructor.
......
from __future__ import (absolute_import, division, print_function)
import mpl_toolkits.basemap as bm
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import cm
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
######################################
# pyplot-free version of simpletest.py
######################################
......
from __future__ import (absolute_import, division, print_function)
# example showing how to use streamlines to visualize a vector
# flow field (from Hurricane Earl).
# Requires matplotlib 1.1.1 or newer.
......@@ -32,11 +34,14 @@ speed = np.sqrt(udat**2+vdat**2)
fig = plt.figure(figsize=(8,8))
m = Basemap(projection='cyl',llcrnrlat=lats1[0],llcrnrlon=lons1[0],urcrnrlat=lats1[-1],urcrnrlon=lons1[-1],resolution='i')
x, y = m(lons,lats)
m.streamplot(x,y,udat,vdat,color=speed,linewidth=2,density=2,cmap=plt.cm.spectral)
m.colorbar()
m.drawmapboundary(fill_color='w')
m.drawcoastlines()
m.drawmeridians(np.arange(-120,-60,2),labels=[0,0,0,1])
m.drawparallels(np.arange(0,30,2),labels=[1,0,0,0])
m.streamplot(x,y,udat,vdat,color=speed,linewidth=2,density=2,cmap=plt.cm.Spectral)
m.colorbar()
plt.title('Hurricane Rita flow field visualized with streamlines',\
fontsize=13)
plt.show()
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
# exercise all the projections by plotting
# etopo bathymetry/topography over them, plus
# drawing coastlines, state and
......@@ -377,7 +378,7 @@ m = Basemap(projection = 'rotpole',lon_0 = -120.,\
llcrnrx = 137, urcrnrx = 222.5, resolution = 'l')
m.drawcoastlines()
ny,nx = lons.shape
m.contourf(lons[ny/2:,:],lats[ny/2:,:],topodat[ny/2:,:],50,cmap=cmap,extend='both',latlon=True)
m.contourf(lons[ny//2:,:],lats[ny//2:,:],topodat[ny//2:,:],50,cmap=cmap,extend='both',latlon=True)
m.drawmeridians(np.arange(-180,180,20),labels=[1,1,1,1])
m.drawparallels(np.arange(20,80,20))
m.colorbar()
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
from netCDF4 import Dataset
from mpl_toolkits.basemap import Basemap
import numpy as np
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
......@@ -28,7 +30,7 @@ plt.figure(figsize=(10,6.6666))
epsg = 2263; width=600.e3; height = 400.e3
m=Basemap(epsg=epsg,resolution='h',width=width,height=height)
# specify a different server.
m.arcgisimage(server='http://maps.ngdc.noaa.gov',service='etopo1',verbose=True)
m.arcgisimage(server='https://gis.ngdc.noaa.gov/arcgis',service='etopo1',verbose=True)
m.drawmeridians(np.arange(-180,180,2),labels=[0,0,0,1])
m.drawparallels(np.arange(0,80,1),labels=[1,0,0,0])
m.drawcoastlines(linewidth=0.25)
......
from __future__ import (absolute_import, division, print_function)
"""
example showing how to plot data from a DEM file and an ESRI shape file using
gdal (http://pypi.python.org/pypi/GDAL).
......
from __future__ import (absolute_import, division, print_function)
"""
example showing how to use OWSlib to retrieve an image
from a WMS server and display it on a map (using the
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
import pyproj
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
......
from __future__ import print_function
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import numpy as np
import matplotlib.pyplot as plt
......
from __future__ import (absolute_import, division, print_function)
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
......
from __future__ import (absolute_import, division, print_function)
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
......
from __future__ import (absolute_import, division, print_function)
"""
Module for plotting data on maps with matplotlib.
......@@ -13,8 +15,15 @@ heavy lifting), and the following functions:
:func:`addcyclic`: Add cyclic (wraparound) point in longitude.
"""
from distutils.version import LooseVersion
try:
from urllib import urlretrieve
from urllib2 import urlopen
except ImportError:
from urllib.request import urlretrieve, urlopen
from matplotlib import __version__ as _matplotlib_version
from matplotlib.cbook import is_scalar, dedent
from matplotlib.cbook import dedent
# check to make sure matplotlib is not too old.
_matplotlib_version = LooseVersion(_matplotlib_version)
_mpl_required_version = LooseVersion('0.98')
......@@ -1296,7 +1305,7 @@ class Basemap(object):
# numpy array (first column is lons, second is lats).
polystring = bdatfile.read(bytecount)
# binary data is little endian.
b = np.array(np.fromstring(polystring,dtype='<f4'),'f8')
b = np.array(np.frombuffer(polystring,dtype='<f4'),'f8')
b.shape = (npts,2)
b2 = b.copy()
# merge polygons that cross dateline.
......@@ -1701,10 +1710,10 @@ class Basemap(object):
if zorder is not None:
spine.set_zorder(zorder)
if self.projection not in ['geos','ortho','nsper']:
limb = ax.axesPatch
limb = ax.patch
if limb is not None:
if limb is not ax.axesPatch:
if limb is not ax.patch:
ax.add_patch(limb)
self._mapboundarydrawn = limb
if fill_color is None:
......@@ -3729,7 +3738,8 @@ class Basemap(object):
# set axes limits to fit map region.
self.set_axes_limits(ax=ax)
# clip to map limbs
ret,c = self._cliplimb(ax,ret)
ret.lines,c = self._cliplimb(ax,ret.lines)
ret.arrows,c = self._cliplimb(ax,ret.arrows)
# streamplot arrows not returned in matplotlib 1.1.1, so clip all
# FancyArrow patches attached to axes instance.
if c is not None:
......@@ -4020,7 +4030,9 @@ class Basemap(object):
try:
import Image
except ImportError:
raise ImportError('warpimage method requires PIL (http://www.pythonware.com/products/pil)')
msg = ('warpimage method requires PIL '
'(http://pillow.readthedocs.io)')
raise ImportError(msg)
from matplotlib.image import pil_to_array
if self.celestial:
......@@ -4048,7 +4060,6 @@ class Basemap(object):
else:
newfile = False
if file.startswith('http'):
from urllib import urlretrieve
self._bm_file, headers = urlretrieve(file)
else:
self._bm_file = file
......@@ -4208,7 +4219,6 @@ class Basemap(object):
returns a matplotlib.image.AxesImage instance.
"""
import urllib2
if not hasattr(self,'epsg'):
msg = dedent("""
Basemap instance must be creating using an EPSG code
......@@ -4243,12 +4253,13 @@ imageSR=%s&\
size=%s,%s&\
dpi=%s&\
format=png32&\
transparent=true&\
f=image" %\
(server,service,xmin,ymin,xmax,ymax,self.epsg,self.epsg,xpixels,ypixels,dpi)
# print URL?
if verbose: print basemap_url
if verbose: print(basemap_url)
# return AxesImage instance.
return self.imshow(imread(urllib2.urlopen(basemap_url)),ax=ax,
return self.imshow(imread(urlopen(basemap_url)),ax=ax,
origin='upper')
def wmsimage(self,server,\
......@@ -4293,7 +4304,7 @@ f=image" %\
from owslib.wms import WebMapService
except ImportError:
raise ImportError('OWSLib required to use wmsimage method')
import urllib2, io
import io
ax = kwargs.pop('ax', None) or self._check_ax()
if not hasattr(self,'epsg'):
msg = dedent("""
......@@ -4321,17 +4332,17 @@ f=image" %\
# ypixels not given, find by scaling xpixels by the map aspect ratio.
if ypixels is None:
ypixels = int(self.aspect*xpixels)
if verbose: print server
if verbose: print(server)
wms = WebMapService(server)
if verbose:
print 'id: %s, version: %s' %\
(wms.identification.type,wms.identification.version)
print 'title: %s, abstract: %s' %\
(wms.identification.title,wms.identification.abstract)
print 'available layers:'
print list(wms.contents)
print 'projection options:'
print wms[kwargs['layers'][0]].crsOptions
print('id: %s, version: %s' %
(wms.identification.type,wms.identification.version))
print('title: %s, abstract: %s' %
(wms.identification.title,wms.identification.abstract))
print('available layers:')
print(list(wms.contents))
print('projection options:')
print(wms[kwargs['layers'][0]].crsOptions)
# remove keys from kwargs that are over-ridden
for k in ['format','bbox','service','size','srs']:
if 'format' in kwargs: del kwargs['format']
......@@ -4342,8 +4353,6 @@ f=image" %\
# this works for png and jpeg.
return self.imshow(imread(io.BytesIO(img.read()),
format=format),origin='upper',alpha=alpha,ax=ax)
# this works for png, but not jpeg
#return self.imshow(imread(urllib2.urlopen(img.url),format=format),origin='upper')
def drawmapscale(self,lon,lat,lon0,lat0,length,barstyle='simple',\
units='km',fontsize=9,yoffset=None,labelstyle='simple',\
......@@ -4980,12 +4989,11 @@ def interp(datain,xin,yin,xout,yout,checkbounds=False,masked=False,order=1):
dataout = map_coordinates(datain,coords,order=3,mode='nearest')
else:
raise ValueError('order keyword must be 0, 1 or 3')
if masked and isinstance(masked,bool):
dataout = ma.masked_array(dataout)
if masked:
newmask = ma.mask_or(ma.getmask(dataout), xymask)
dataout = ma.masked_array(dataout,mask=newmask)
elif masked and is_scalar(masked):
dataout = np.where(xymask,masked,dataout)
dataout = ma.masked_array(dataout, mask=newmask)
if not isinstance(masked, bool):
dataout = dataout.filled(masked)
return dataout
def shiftgrid(lon0,datain,lonsin,start=True,cyclic=360.0):
......@@ -5091,7 +5099,7 @@ def addcyclic(*arr,**kwargs):
if len(arr) == 1:
return _addcyclic_lon(arr[-1])
else:
return map(_addcyclic,arr[:-1]) + [_addcyclic_lon(arr[-1])]
return list(map(_addcyclic,arr[:-1]) + [_addcyclic_lon(arr[-1])])
def _choosecorners(width,height,**kwargs):
"""
......@@ -5174,7 +5182,7 @@ def _readlsmask(lakes=True,resolution='l',grid=5):
gzip.open(os.path.join(basemap_datadir,'lsmask_%smin_%s.bin' %\
(grid,resolution)), 'rb')
lsmask =\
np.reshape(np.fromstring(lsmaskf.read(),dtype=np.uint8),(nlats,nlons))
np.reshape(np.frombuffer(lsmaskf.read(),dtype=np.uint8),(nlats,nlons))
if lakes:
lsmask =\
np.where(lsmask==2,np.array(0,dtype=np.uint8),lsmask)
......
from __future__ import (absolute_import, division, print_function)
"""
extra colormaps:
......@@ -11,6 +13,8 @@ GMT_wysiwyg
run examples/show_colormaps.py to see what these colormaps look like.
"""
from six import iteritems
from matplotlib import rcParams, colors
_LUTSIZE = rcParams['image.lut']
......@@ -70,7 +74,7 @@ datad['sstanom']=_sstanom_data
def _revcmap(data):
data_r = {}
for key,val in data.iteritems():
for key,val in iteritems(data):
val = list(val)
valrev = val[::-1]
valnew = []
......@@ -79,7 +83,7 @@ def _revcmap(data):
data_r[key]=valnew
return data_r
_cmapnames = datad.keys()
_cmapnames = list(datad.keys())
for _cmapname in _cmapnames:
_cmapname_r = _cmapname+'_r'
_cmapdat_r = _revcmap(datad[_cmapname])
......
from __future__ import (absolute_import, division, print_function)
"""
These are diagnostic and debugging functions for basemap.
"""
......@@ -52,13 +54,8 @@ def package_versions():
OWSLib_version = 'not installed'
try:
from PIL import VERSION as pil_version
try:
from PIL import PILLOW_VERSION as pillow_version
except ImportError:
pillow_version = 'not installed'
from PIL import __version__ as pillow_version
except ImportError:
pil_version = 'not installed'
pillow_version = 'not installed'
......@@ -66,7 +63,7 @@ def package_versions():
'BasemapPackageVersions',
"""Python, basemap, matplotlib,
numpy, pyproj, pyshp, PROJ4, geodesic,
GEOS, OWSLib, PIL, Pillow""")
GEOS, OWSLib, Pillow""")
return BasemapPackageVersions(
Python = sys_version,
......@@ -80,7 +77,6 @@ def package_versions():
GEOS = _geoslib.__geos_version__,
# optional dependencies below
OWSLib = OWSLib_version,
PIL = pil_version,
Pillow = pillow_version)
def check_proj_inv_hammer(segfault_protection=True):
......
from __future__ import (absolute_import, division, print_function)
import numpy as np
import pyproj
import math
......
from __future__ import (absolute_import, division, print_function)
# some simple functions to calculate solar position, day-night terminator
import numpy as np
from numpy import ma
......
from __future__ import (absolute_import, division, print_function)
from distutils.version import LooseVersion
import sys
from mpl_toolkits.basemap import Basemap, shiftgrid
......@@ -240,6 +242,13 @@ class TestInputValidation(TestCase):
assert bmap1.proj4string == bmap2.proj4string
class TestOrthoProjPolygons(TestCase):
def test_basemapcreation_should_not_fail(self):
# different resolutions should work
for r in ['c', 'l', 'i', 'h', 'f']:
m = Basemap(projection='ortho',resolution=r,lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
pass
def test():
"""
Run some tests.
......
import sys, glob, os, subprocess
from __future__ import (absolute_import, division, print_function)
import glob
import io
import os
import sys
from setuptools.dist import Distribution
if sys.version_info < (2, 6):
raise SystemExit("""matplotlib and the basemap toolkit require Python 2.6 or later.""")
from distutils.dist import Distribution
from distutils.util import convert_path
from distutils import ccompiler, sysconfig
# Do not require numpy for just querying the package
# Taken from the netcdf-python setup file (which took it from h5py setup file).
inc_dirs = []
if any('--' + opt in sys.argv for opt in Distribution.display_option_names +
['help-commands', 'help']) or sys.argv[1] == 'egg_info':
from distutils.core import setup, Extension
from setuptools import setup, Extension
else:
import numpy
# Use numpy versions if they are available.
......@@ -20,10 +22,14 @@ else:
# append numpy include dir.
inc_dirs.append(numpy.get_include())
try:
from distutils.command.build_py import build_py_2to3 as build_py
except ImportError:
from distutils.command.build_py import build_py
def get_install_requirements(path):
path = os.path.join(os.path.dirname(__file__), path)
with io.open(path, encoding='utf-8') as fp:
content = fp.read()
return [req for req in content.split("\n")
if req != '' and not req.startswith('#')]
def checkversion(GEOS_dir):
"""check geos C-API header file (geos_c.h)"""
......@@ -77,7 +83,7 @@ set GEOS_DIR to /usr/local), or edit the setup.py script
manually and set the variable GEOS_dir (right after the line
that says "set GEOS_dir manually here".""" % "', '".join(geos_search_locations))
else:
geos_include_dirs=[os.path.join(GEOS_dir,'include'),inc_dirs]
geos_include_dirs=[os.path.join(GEOS_dir,'include')] + inc_dirs
geos_library_dirs=[os.path.join(GEOS_dir,'lib'),os.path.join(GEOS_dir,'lib64')]
packages = ['mpl_toolkits','mpl_toolkits.basemap']
......@@ -108,14 +114,9 @@ datafiles = glob.glob(os.path.join(pathout,'*'))
datafiles = [os.path.join('data',os.path.basename(f)) for f in datafiles]
package_data = {'mpl_toolkits.basemap':datafiles}
requirements = [
"numpy>=1.2.1",
"matplotlib>=1.0.0",
"pyproj >= 1.9.3",
"pyshp >= 1.2.0"
]
install_requires = get_install_requirements("requirements.txt")
__version__ = "1.1.0"
__version__ = "1.2.0"
setup(
name = "basemap",
version = __version__,
......@@ -131,7 +132,7 @@ setup(
author_email = "jeffrey.s.whitaker@noaa.gov",
maintainer = "Ben Root",
maintainer_email = "ben.v.root@gmail.com",
install_requires = requirements,
install_requires = install_requires,
platforms = ["any"],
license = "OSI Approved",
keywords = ["python","plotting","plots","graphs","charts","GIS","mapping","map projections","maps"],
......@@ -146,7 +147,6 @@ setup(
packages = packages,
namespace_packages = namespace_packages,
package_dir = package_dirs,
ext_modules = extensions,
cmdclass = {'build_py': build_py},
ext_modules = extensions,
package_data = package_data
)
This diff is collapsed.
......@@ -335,15 +335,17 @@ cdef class Polygon(BaseGeometry):
cdef GEOSCoordSeq *cs
cdef GEOSGeom *lr
# make sure data is contiguous.
# if not, make a local copy.
if not PyArray_ISCONTIGUOUS(b):
b = b.copy()
m = b.shape[0]
# Add closing coordinates to sequence?
if b[-1,0] != b[0,0] or b[-1,1] != b[0,1]:
if m > 0 and (b[-1,0] != b[0,0] or b[-1,1] != b[0,1]):
M = m + 1
else:
M = m
......