In today's data-driven world, visualizing information on maps has become essential for valuable insights. Luckily python developers have just the library to help with that. Basemap is a Python library that enables developers to create maps and visualize other 2D geographical information. With this library, you can elevate your mapping capabilities to new heights.

If you are not familiar with the Basemap Library, it is a toolkit built on the foundation of matplotlib to help with the plotting and manipulation of geographical data. The library offers a wide range of map projections, geographical transformations, and various tools for overlaying data onto maps. With all these, you get to visualize and analyze spatial information such as weather patterns, population density, transportation networks, and more.

If this is what you are looking for, this guide gives you a step-by-step guide on how to install the Basemap Python Library in Ubuntu to get started on your project.

Let's get started.

Installing the Basemap Library via the Terminal

The first step is to update Ubuntu packages to ensure the package list is up to date and missing packages are installed. To do this, open the terminal by pressing the Ctrl + Alt + t and use the following command.

sudo apt update

Before the Basemap Library is installed, several dependencies should be installed to avoid conflicts and errors. They include Python and its package manager pip. To install these dependencies on your Linux system, use the command below.

sudo apt install libgeos-dev libproj-dev python3 python3-pip

When prompted, press Y then Enter to continue the installation.

Now that the foundation has been created, we can now install the Basemap Library on your Ubuntu System.

To do this, use the Python package manager (pip) to download and install the Basemap Library. Here is the command:

pip install basemap --user

This command will download all the required Basemap dependencies and packages onto your system. You should see something like this on the terminal.

Once the installation is complete, you can confirm the Basemap Library is installed on your machine with the following command.

python3 -m pip show basemap

If everything is installed correctly, you should have a similar output.

Using Basemap to Create a World Map

We can test out the installed library by writing a script that outputs the world map in a window with controls for the size.

Start by creating a file for the code.


Open the file created with the editor of your choice. In this demonstration, vim is used. Learn how to use Vim.


Paste the following code in the editor.

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt

# Create a Basemap object
map = Basemap()

# Draw a basic map

# Display the map

When done, Save the file and exit the editor. You can do that by pressing :wq on your keyboard then Enter as shown in the image above.

Run the file with the command below.

python3 filename

where the filename is what you named your project. In this case, the project name is




This guide gives a quick introduction to getting started with the Basemap Python Library. You get to learn how to install the library and use it to create an outline of the world map. For more information on how to use the Basemap Library, visit the official Basemap documentation. If you found the article helpful, be sure to subscribe and share it with those that may be interested.

Thank you for reading : )

Table of Contents
Great! Next, complete checkout for full access to GeekBits.
Welcome back! You've successfully signed in.
You've successfully subscribed to GeekBits.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info has been updated.
Your billing was not updated.