Created
October 14, 2020 16:26
-
-
Save focaalvarez/c68bf4ab158cc843aa58eafa162efc3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import json | |
from urllib.request import urlopen | |
import numpy as np | |
#Load GeoJson | |
with urlopen('https://opendata.arcgis.com/datasets/48b6b85bb7ea43699ee85f4ecd12fd36_4.geojson') as response: | |
counties = json.load(response) | |
#Load data to be charted | |
dummy_data=pd.read_csv('https://opendata.arcgis.com/datasets/48b6b85bb7ea43699ee85f4ecd12fd36_0.csv?outSR=%7B%22latestWkid%22%3A27700%2C%22wkid%22%3A27700%7D') | |
#add dummy data | |
dummy_data['value']=np.random.randint(10, 100, size=len(dummy_data)) | |
#With Folium | |
import folium | |
m = folium.Map(tiles='cartodbpositron',location=[54.38, -2.7], zoom_start = 6.499) | |
folium.Choropleth(geo_data=counties, name='choropleth', data=dummy_data, columns=['nuts218cd', 'value'], | |
key_on='feature.properties.nuts218cd', fill_color='YlGnBu', fill_opacity=0.7, line_opacity=0.2, | |
legend_name='LEGEND',highlight=True).add_to(m) | |
m.save('#292_folium_chloropleth_4USA1.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment