Basemap is a deprecated Python library for plotting 2D data on map projections with Matplotlib. While it enabled various map projections, coastlines, and geopolitical boundaries, it is no longer actively developed and is officially superseded by Cartopy. The current version is 2.0.0.
pip install basemapVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a Basemap instance with a 'mill' (Miller cylindrical) projection, draw basic map features like coastlines and meridians, and save the output to a file. Remember that Basemap is deprecated.
Migrate new code to `cartopy` or `geopandas`. For existing projects, consider a migration strategy.
Ensure PROJ 6+ (e.g., `libproj.so.19` or `proj.dll` for PROJ 9+) and GEOS are installed on your system. Using `conda install -c conda-forge basemap` is often the most reliable way as it handles these dependencies.
Experiment with `figsize` in `plt.figure()`, and specific projection parameters like `lon_0`, `lat_0`, `width`, `height`, and `resolution` in the `Basemap` constructor. Consult Basemap examples for appropriate parameters for different projections and regions.
Stick to the Matplotlib version range specified in Basemap's dependencies. If using Basemap, avoid aggressively upgrading Matplotlib unless compatibility is explicitly verified.
Install PROJ at the system level: `sudo apt-get install libproj-dev proj-data` (Ubuntu/Debian) or `brew install proj` (macOS). Alternatively, use `conda install -c conda-forge basemap` which bundles these dependencies.
`pip install basemap` or, more reliably for its C-level dependencies, `conda install -c conda-forge basemap`. Verify installation with `python -c "import mpl_toolkits.basemap"`.
Ensure you are calling methods on the `Basemap` instance (e.g., `m.plot`, `m.scatter`, or `m(lon, lat, inverse=False)`) and not treating the instance `m` itself as a function for coordinate transformation.
Downgrade or upgrade Matplotlib to a compatible version. For example, `pip install 'matplotlib>=3.5.0,<3.7.0'` to match Basemap 2.0.0's requirements, or check the Basemap documentation for the latest compatibility.