Generate MAP in Python

Sharing Video and scripts use the coordinates for New Delhi, India and will display a map centered in India. You can use the Visual Studio version to generate an HTML file, and the Jupyter Notebook version for inline map rendering. 

I personally Prefer Visual Studio for PYTHON code or data analysis hence sharing both codes for your reference   i used this in my visual studio and below is snip for your reference adding a code so you can run in your system 

map in python

# code by discover talent presents

import folium

# Correct map center at the specified coordinates (New Delhi, India)

map_center = (28.6139, 77.2090)

# Create the map object

mymap = folium.Map(location=map_center, zoom_start=12)

# Add a marker at New Delhi, India

folium.Marker(

    [28.6139, 77.2090],

    popup="India",

    icon=folium.Icon(color="blue", icon="info-sign") ).add_to(mymap)

# Save the map to an HTML file

mymap.save("mymap.html")

# Inform the user that the map has been saved

print("Map has been saved to mymap.html")

How to Run (Visual Studio):

  • After running this script, an HTML file named mymap.html will be generated.
  • Open mymap.html in your web browser to view the map centered in India.
Also sharing code for JUPYTER Notebook 

Version 2: Code for Jupyter Notebook

In Jupyter Notebook, you can display the map interactively without saving it as a file:


# code by discover talent presents
import folium

# Correct map center at the specified coordinates (New Delhi, India)
map_center = (28.6139, 77.2090)

# Create the map object
mymap = folium.Map(location=map_center, zoom_start=12)

# Add a marker at New Delhi, India
folium.Marker(
    [28.6139, 77.2090],
    popup="India",
    icon=folium.Icon(color="blue", icon="info-sign")
).add_to(mymap)

# Display the map directly in Jupyter Notebook
mymap

use the coordinates for New Delhi, India and will display a map centered in India. You can use the Visual Studio version to generate an HTML file, and the Jupyter Notebook version for inline map rendering.


Comments

Popular posts from this blog

Finance Dashboard in Excel

Build an Automated Financial Dashboard in Microsoft Excel – Complete 1-Hour Udemy Course

Excel Not Responding? Fix Freezing Instantly with Manual Calculation