How To Import Folium In Jupyter Notebook

How To Articles

Hey there! So you’re interested in learning how to import Folium in Jupyter Notebook? Great choice! Folium is a powerful Python library that allows you to create interactive maps and visualize geospatial data.

First, let’s make sure you have Jupyter Notebook installed on your machine. If you don’t have it yet, no worries! You can easily install it by following the instructions on the official Jupyter Notebook website.

Once you have Jupyter Notebook up and running, it’s time to install Folium. Open up your Jupyter Notebook environment and create a new Python notebook. Now, let’s install the Folium library by running the following command in a code cell:

!pip install folium

This command will utilize pip, the Python package manager, to download and install the Folium library and all its dependencies.

After the installation is complete, you can import the Folium library into your Jupyter Notebook by executing the following code:

import folium

Now that Folium is imported, you’re ready to start creating awesome interactive maps! Let’s dive into some of Folium’s key features and how you can utilize them in Jupyter Notebook.

Creating a Basic Map

To begin, let’s create a basic map with Folium. Use the following code snippet to generate a map centered at a specific location with an initial zoom level:

my_map = folium.Map(location=[latitude, longitude], zoom_start=12)

Replace latitude and longitude with the coordinates of the location you want to center your map on. You can also adjust the zoom_start parameter to control the initial zoom level of the map.

Once you have defined your map, you can display it in your Jupyter Notebook by simply running the following code:


This will render the map as an interactive component directly in your Jupyter Notebook.

Adding Markers to the Map

One of Folium’s standout features is its ability to add markers and other interactive elements to maps. Let’s take a look at how you can add markers to your map.

To add a marker to your map, you can use the following code:

folium.Marker([latitude, longitude], popup='Marker Name').add_to(my_map)

Replace latitude and longitude with the coordinates of the location where you want to place the marker. You can also customize the appearance of the marker by specifying additional parameters, such as the marker icon or color.

Feel free to add as many markers as you like to your map! You can even customize the popups associated with each marker to display additional information when clicked.


And there you have it! You’ve learned how to import Folium in Jupyter Notebook and use its powerful features to create interactive maps. Whether you’re visualizing geospatial data or simply exploring different locations, Folium is an excellent tool to have in your Python toolkit.

Remember, practice makes perfect! Take some time to experiment with Folium and explore its various functionalities. By combining your creativity with Folium’s capabilities, you’ll be able to create stunning and informative maps in no time.

Happy mapping!