MITB Banner

Hands-on Tutorial On Folium, Python Library For Geographical Data Visualization

In this article, we will explore Folium, a python library which is used to create different types of geographical data visualizations. We will try and create different types of maps and markers on maps.

Share

Folium- Geographical Data Visualization

Geographical data is defined as the data which is relative to a certain location. As it is a location on earth we can represent it on a map. Representing geographical data on a map is easy using python libraries.  

Python provides different open-source libraries for geographical data visualization. These libraries are easy to use and create highly interactive and visually appealing maps. 

In this article, we will explore Folium, a python library which is used to create different types of geographical data visualizations. We will try and create different types of maps and markers on maps. 

Implementation: 

We will start by installing Folium using pip install folium.

  1. Importing required libraries

We will import folium which contains all the functions that are required for geographical data visualization.

import folium

  1. Exploring Folium

We will start exploring folium by creating a world map in just one line of code.

world_map = folium.Map()

world_map

World Map using Folium

Similarly, we can create maps for different locations by just passing the Longitude and Latitude of the respective location. Let us plot the Bangalore Map using folium. You can google the Latitude and Longitude of your respective location.

  • Creating a map of Bangalore

bang_map = folium.Map(location=[12.9716, 77.5946], zoom_start=12)

bang_map

Bangalore Map using Folium
  • Creating a world map with Markers

Folium allows us to create a marker on the map for a particular location by using the marker function. Let us explore it by marking capitals of some countries on the world map.

cap = folium.Map(zoom_start=6)

folium.Marker(location=[28.7041, 77.1025 ], popup='Delhi').add_to(cap)

folium.Marker(location=[39.9042, 116.4074], popup='Beijing').add_to(cap)

folium.Marker(location=[55.7558, 37.6173], popup='Moscow').add_to(cap)

  • Different Styles of Map

Folium supports different types of map formats that clearly display different attributes like Roads, Rivers, etc. Let us explore different types of maps using coordinates of India.

First, we will explore the Stamen Toner map which is a high contrast Black & White map which helps in visualizing the river meanders and coastal zones clearly and then Stamen Terrain which shows hill shading and natural vegetation colors.

  1. Stamen Toner

india_map =folium.Map(location=[20.5937, 78.9629 ],zoom_start=5,   tiles='Stamen Toner')

india_map

India Map in Stamen Toner
  1. Stamen Terrain

india_map =folium.Map(location=[20.5937, 78.9629 ], zoom_start=5, tiles='Stamen Terrain')

india_map

You can see in the output images how clearly these tiles work to show different attributes of the geographical area. Similarly, you can explore many more tile styles that are there in folium.

Folium allows us to create interactive maps in just a single line of code and of different types and locations. You can zoom-in or zoom-out of the maps to get a clear picture of the location and the surroundings.

Conclusion:

In this article, we explored the basics of folium, how we can create different maps with different styles in just a single line of code. We saw how we can create a marker on the map to notify the respective location. We saw how different parameters can change the view and style of the map. 

We saw that folium is a powerful library that is used to create highly interactive leaflet maps with different views and styles

Share
Picture of Himanshu Sharma

Himanshu Sharma

An aspiring Data Scientist currently Pursuing MBA in Applied Data Science, with an Interest in the financial markets. I have experience in Data Analytics, Data Visualization, Machine Learning, Creating Dashboards and Writing articles related to Data Science.
Related Posts

CORPORATE TRAINING PROGRAMS ON GENERATIVE AI

Generative AI Skilling for Enterprises

Our customized corporate training program on Generative AI provides a unique opportunity to empower, retain, and advance your talent.

Upcoming Large format Conference

May 30 and 31, 2024 | 📍 Bangalore, India

Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

AI Forum for India

Our Discord Community for AI Ecosystem, In collaboration with NVIDIA. 

Flagship Events

Rising 2024 | DE&I in Tech Summit

April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore

MachineCon GCC Summit 2024

June 28 2024 | 📍Bangalore, India

MachineCon USA 2024

26 July 2024 | 583 Park Avenue, New York

Cypher India 2024

September 25-27, 2024 | 📍Bangalore, India

Cypher USA 2024

Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA

Data Engineering Summit 2024

May 30 and 31, 2024 | 📍 Bangalore, India