In this article, we will explore Folium, a Python library which makes it easy makes it easy to visualize data that’s been manipulated in Python on an interactive leaflet map.

The maps created using folium are highly interactive which makes it even more useful for dashboard building. So let’s start exploring Folium and learn on our way of exploring it.

Installing Folium

We can install folium by running the following given below command in our command prompt.

pip install folium

Creating a world map using folium

After installing folium we need to import it in our Jupiter notebook to start working. Folium is an easy to understand library by which you can create highly interactive and visually appealing maps in just a few lines of code.

Here we will learn how we can use it to create a world map. For this, we just need to call the Map() function. The code given below will help you understand this better.

#importing folium library
import folium

# calling Map() function
world_map = folium.Map()
#displaying world map
world_map

Map using Folium with just one line of code.

The map created above is interactive i.e. you can actually zoom-in and zoom-out of the map using the ‘+’ and ‘-’ or by just using the cursor of your mouse.

We can pass the ‘location’ argument which contains the longitude and latitude of a particular location to Map() function to display the map of the desired location. For example, you can see the code below I used to create the map of Russia using its coordinates. Here I have also passed an attribute named ‘zoom_start’ which already zoom-in accordingly.

mah_map = folium.Map(location=[61.5240, 105.3188], zoom_start=3)
mah_map

Russia’s Map created using Folium

Further, you can use folium for creating different types of maps. Some of them I have explained below.

#data-science #dashboard #python #data-visualization #maps #programming

Folium: Create Interactive Leaflet Maps
2.20 GEEK