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

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

Himanshu Sharma
Folium- Geographical Data Visualization
W3Schools

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.

See Also
Autoplotter Tutorial

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

What Do You Think?

If you loved this story, do join our Telegram Community.


Also, you can write for us and be one of the 500+ experts who have contributed stories at AIM. Share your nominations here.

Copyright Analytics India Magazine Pvt Ltd

Scroll To Top