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.
We will start by installing Folium using pip install folium.
- Importing required libraries
We will import folium which contains all the functions that are required for geographical data visualization.
- Exploring Folium
We will start exploring folium by creating a world map in just one line of code.
world_map = folium.Map()
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)
- 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.
- Stamen Toner
india_map =folium.Map(location=[20.5937, 78.9629 ],zoom_start=5, tiles='Stamen Toner')
- Stamen Terrain
india_map =folium.Map(location=[20.5937, 78.9629 ], zoom_start=5, tiles='Stamen Terrain')
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.
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.
Join Our Telegram Group. Be part of an engaging online community. Join Here.
Subscribe to our NewsletterGet the latest updates and relevant offers by sharing your email.
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.