Created
June 15, 2022 03:56
-
-
Save amitrani6/f8f63046c428c2e9f4562b914cc96eea to your computer and use it in GitHub Desktop.
This file contains hidden or 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 branca | |
# Create the map object | |
m = folium.Map(location=[48, -102], zoom_start=3) | |
# Create the colomap styles | |
colormap = branca.colormap.LinearColormap( | |
vmin=us_data_gdf["Total_Pop_2021"].quantile(0.0), | |
vmax=us_data_gdf["Total_Pop_2021"].quantile(1), | |
colors=["red", "orange", "lightblue", "green", "darkgreen"], | |
caption="Total Population By State", | |
) | |
# Create the Choropleth | |
folium.GeoJson( | |
us_data_gdf, | |
style_function=lambda x: { | |
"fillColor": colormap(x["properties"]["Total_Pop_2021"]) | |
if x["properties"]["Total_Pop_2021"] is not None | |
else "transparent", | |
"color": "black", | |
"fillOpacity": 0.4, | |
}, | |
).add_to(m) | |
# Display the Choropleth | |
m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment