Plot on map projections (with coastlines and political boundaries) using
matplotlib
.
Precompiled binary wheels for Windows, GNU/Linux and MacOS are available
on PyPI and can be installed with pip
:
python -m pip install basemap
Otherwise, you will need to install basemap
from its source hosted
on GitHub as indicated in the following steps:
-
Install pre-requisite Python modules:
-
Download the
basemap
source code:git clone --depth 1 https://github.com/matplotlib/basemap.git
-
Build the GEOS library. You may use the helper provided in
utils
, (please note that you needCMake
and a working C compiler in advance):export GEOS_DIR=<your desired location> python -c "import utils; utils.GeosLibrary('3.6.5').build(installdir='${GEOS_DIR}')"
or you can link directly to the system library if it is already installed.
GEOS_DIR
must point to the GEOS installation prefix; e.g. iflibgeos_c.so
is located in/usr/lib
andgeos_c.h
is located in/usr/include
, then you must setGEOS_DIR
to/usr
. -
Build and install the
basemap
binary wheel:python -m pip install .
On Linux, if your Python was installed through a package management system, make sure that you have the Python header
Python.h
required to build Cython extensions (e.g. on Debian-like systems, you should have the packagepython-dev
installed). -
Check that the package was installed correctly by executing:
python -c "from mpl_toolkits.basemap import Basemap"
This package depends on basemap-data
with the basic basemap
data assets supporting the essential functionality.
This package depends optionally on basemap-data-hires
with the
high-resolution data assets, which can be installed with pip
:
python -m pip install basemap-data-hires
This package depends optionally on OWSLib
for the Basemap
method
Basemap.wmsimage
.
The library is licensed under the terms of the MIT license (see
LICENSE
). The GEOS dynamic library bundled with the package wheels
is provided under the terms of the LGPL-2.1-only license as given in
LICENSE.geos
.
See https://matplotlib.org/basemap/.
See scripts in the doc/examples
directory for example usage.
Read the FAQ and/or email the matplotlib-users mailing list if you have problems or questions.
Ben Root ben.v.root@gmail.com
Víctor Molina García (@molinav)
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.
The Basemap.fillcontinents
method doesn't always do the right thing.
Matplotlib always tries to fill the inside of a polygon. Under certain
situations, what is the inside of a coastline polygon can be ambiguous,
and the outside may be filled instead of the inside. A workaround is to
change the map projection region slightly or mask the land areas with
the Basemap.drawlsmask
method instead of filling the coastline
polygons (this is illustrated in the ortho_demo.py
example).