-1

I have an excel file containing some latitudes and longitudes in Iran. I want to show the routes to each of these locations accurately on the map in python in Jupyter.

I have tried many ways and I don't have access to paid APIs. I used osmnx and it wasn't able to show the routes on the map for the locations I had.

  • Can you give an example of the osmnx code you tried? How far apart are the locations? osmnx has trouble routing between locations which are very far apart. – Nick ODell Apr 18 '23 at 20:43
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Apr 19 '23 at 05:57

1 Answers1

0

Try this way;

    import pandas as pd
    import folium

    # Read the Excel file with the latitudes and longitudes
    data = pd.read_excel('your_excel_file.xlsx')

    # Create a map centered on Iran
    iran_map = folium.Map(location=[32.4279, 53.6880], zoom_start=5)

    # Loop through the data and add markers for each location
    for i, row in data.iterrows():
        folium.Marker([row['Latitude'], row['Longitude']], 
                    popup=row['Location']).add_to(iran_map)

    # Add a line to connect the markers
    locations = data[['Latitude', 'Longitude']].values.tolist()
    folium.PolyLine(locations, color='red').add_to(iran_map)

    # Show the map
    iran_map
foysalf652
  • 208
  • 1
  • 10