packages = [
"folium",
"pandas"
]
import folium
import json
import pandas as pd
import urllib3
from pyodide.http import open_url
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
url = (
"https://docs.google.com/spreadsheets/d/1Ce2UnJCj_goOWb5OIQ9QCPYCh_FgsEQ2sErWn9wonXU/export?format=csv&gid=0"
)
url_content = open_url(url)
population_data = pd.read_csv(url_content)
m = folium.Map(location=[35.7111326404866, 139.66453528858855], zoom_start=14, tiles="cartodb positron")
geo_json = urllib3.request("GET","https://raw.githubusercontent.com/RefletsDansLeau/Nakanoku-geojson/master/nakano_ku_85cho.json",preload_content=False).json()
folium.Choropleth(
geo_data=geo_json,
name="choropleth",
data=population_data,
columns=['KEYCODE1','総数0から4歳'],
key_on="feature.properties.KEYCODE1",
fill_color="YlGn",
fill_opacity=0.7,
line_opacity=0.2,
).add_to(m)
folium.LayerControl().add_to(m)
display(m, target="folium")