<jupyter_start><jupyter_text>*** Interactive OpenStreet Map of Nigeria's Covid Cases*** In this notebook I will create an interactive Openstreet map that details the covid death cases in Nigeria as at Dec 2021 on a state-by-state basis \** ***The data was scrapped from the National Center for Diseases Control (NCDC) website and formatted into a csv file.*** First, we import the necessary modules, some of which require certain dependencies to be installed:<jupyter_code>import pandas as pd

pip install geopy
pip install folium
!apt install gdal-bin python-gdal python3-gdal 
!apt install python3-rtree 
!pip install git+git://github.com/geopandas/geopandas.git
from geopandas.tools import geocode<jupyter_output><empty_output><jupyter_text>We import raw data for the actual work<jupyter_code>from google.colab import files
Uploaded= files.upload()
df= pd.read_csv('Ncdc data.csv')
df<jupyter_output><empty_output><jupyter_text>The dataset is then geocoded and necessary adjustments made:<jupyter_code>df1 = df.copy()
from typing import Type
for i, row in df1.iterrows():
  try:
    info= geocode(str(row['States Affected']), provider='nominatim')
    df1.loc[int(i), 'Latitude'] = info['geometry'].loc[0].y
    df1.loc[int(i), 'Longitude'] = info['geometry'].loc[0].x
  except TypeError:
    Print('Nan')


info

df1.head()
df1.to_csv('New_df.csv')
import folium
new_dataset= pd.read_csv('New_df.csv')
new_dataset.head()
del new_dataset['Unnamed: 0']

new_dataset.head()<jupyter_output><empty_output><jupyter_text>Using folium, the map is created:<jupyter_code>m =folium.Map(tiles= 'OpenStreetmap', zoom_start= 2)

for index, row in new_dataset.iterrows():
  folium.Marker([row['Latitude'], row['Longitude']], popup= 'State: '+row['States Affected']+ '<br>' '<br>' 'Number of Death Cases as at Dec 2021: ' + str(row['Number of Deaths'])).add_to(m)

m.save('Interactive Map on Covid Cases in Nigeria.html')

m<jupyter_output><empty_output><jupyter_text>Notice how some points on the maps do not fall in their appropriate positions on the map: Niger, Delta, and Borno states have their markers outside of their boundaries. As this is clearly a case of wrong coordinates, we then try to adjust the geometry (latitude and longitude values) of these three areas on the map from the dataset.One way to do this is manually search the OpenStreetMap API for a more suitable location detail for these areas and replace their initial values in the dataset:<jupyter_code>new_dataset.iloc[9,5:]= [5.5859, 5.4382]
new_dataset.iloc[25,5:]= [11.864, 13.195]
new_dataset.iloc[29,5:]= [9.662, 6.520,]


new_dataset<jupyter_output><empty_output><jupyter_text>Now, we re-run the mapping code to plot the now-adjusted dataset for a more precise interactive map, providing a pop-up for the required information.<jupyter_code>m =folium.Map(tiles= 'OpenStreetmap', zoom_start= 2)

for index, row in new_dataset.iterrows():
  folium.Marker([row['Latitude'], row['Longitude']], popup= 'State: '+row['States Affected']+ '<br>' '<br>' 'Number of Death Cases as at Dec 2021 : ' + str(row['Number of Deaths'])).add_to(m)

m.save('Adjusted Interactive Map on Covid Cases in Nigeria.html')
m<jupyter_output><empty_output><jupyter_text>**Our work is done**. On clicking on each marker, the information of the location(state) and death cases recorded are shown.<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11614814814814815, 'fraction_numerical': 0.018074074074074076, 'mean_word_length': 6.092436974789916, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '473761', 'license': 'MIT', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1083, 'n_words': 366, 'path': 'Geodata_Proj_(Interactive_Covid_Map).ipynb', 'repo_name': 'chimaze12/Geodata-Science-Projects-Interactive-Maps-', 'size': '3375'}