1. Read, clean, and prepare data to build maps
1.1. Create your first choropleth world map
1.2. Create dictionaries: JSON and GeoJSON
1.3. Read and clean immigration data
2. Problem & Solution
2.1. Fusion of GeoJson and immigration data
2.2. Create your first map with pinpoints
2.3. Using WITS data to build a bar graph
2.4. Insert a bar graph in a pinpoint map
2.5. Obtaining the risk of each country
Load the notebook with commands developed in steps 2.2 and 2.3. (click on the link):
https://colab.research.google.com/drive/1w0d5xSKCT9XFB5ADHsurutDSyRK78p-E?usp=sharing
The next code helps to insert the bar graph on Zambia pinpoint with the correspondings latitude and longitude.
filter = data['name'] == 'Zambia'
data_filter = data[filter]
data_filter
The filtered data output could be seen:
The next code creates the map with a pinpoint which contains a bar graph element.
# import the library
import folium
# Make an empty map
m = folium.Map(location=[20,0], tiles="OpenStreetMap", zoom_start=2)
# add marker one by one on the map
for i in range(0,len(data_filter)):
folium.Marker(
location=[data_filter.iloc[i]['latitude'], data_filter.iloc[i]['longitude']],
popup=popup,#data_filter.iloc[i]['name'],
lazy=True
).add_to(m)
# Show the map
m
The Python code with all the steps is summarized in this Google Colab (click on the link):
https://colab.research.google.com/drive/1ZxQNqyr3KssnHHIXhmxu1Q_UU7PyVQtL?usp=sharing