How to Create Your Own Map using Python

Rajat upadhyaya
Python in Plain English
2 min readMay 21, 2021

--

In this article, we will learn how to create your own custom map using Python. So, for creating a map, I am using the folium library. You can also read more about this here.

So let's see the coding part.

Here, I have divided the code into 2 parts. In the first part, I will import the library; and in the next part, we will use that library.

STEP no . 1

import folium

So here we imported folium before importing folium we need to install it in our project so for that we have to write in terminal

pip install folium

Step no.2

map = folium.Map(location=[26.44394977471872, 80.3242577190809],zoom_start=15)folium.CircleMarker(location=[26.44394977471872, 80.3242577190809],radius=50,popup = “anyplace”).add_to(map)folium.Marker([26.44394977471872, 80.3242577190809],popup= “unkown place”).add_to(map)folium.Marker([26.4456837706063, 80.3284252105557],popup= “place”).add_to(map)folium.PolyLine(locations=[(26.44394977471872, 80.3242577190809),(26.4456837706063, 80.3284252105557)],line_opacity = 0.6).add_to(map)map.save(“map.html”)

In the first line, we are creating a map variable where we will pass the geographical location value.

And in the second line, we have created a circle around that location. Next, we have created a marker in that location.

So now our custom map is ready.

In the 4th and 5th lines, we have created another location and drawn a polyline between the two locations.

And in the last line, we have saved the map.

I hope you understood each line and enjoyed reading this. Thank you.

More content at plainenglish.io

--

--