Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix states geojson import overriding list of states #35

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

oliviachang29
Copy link
Contributor

Realized that storing the geojson data for the states and storing it in states was overriding the states import from ECHO_modules.geographies! Renamed it to states_geography.

@ericnost
Copy link
Member

ericnost commented Dec 9, 2021

Oh good catch @oliviachang29 !!!

@ericnost
Copy link
Member

ericnost commented Dec 9, 2021

I'll merge the pull. A cleaner approach, in the future, might be to load in the states_geography geojson (or indeed, any spatial data) in the notebook environment and then pass it to the choropleth_mapper() like so:

def state_choropleth_mapper(states_geo, state_data, column, legend_name, color_scheme="PuRd"):
    map = folium.Map()  

    m = folium.Choropleth(
    geo_data = states_geo,
    name="choropleth",
    data=state_data,
    columns=["STUSPS",column],
    .....

and then in the notebook doing:

states_geography = geopandas.read_file("https://raw.githubusercontent.com/edgi-govdata-archiving/ECHO-Geo/main/cb_2018_us_state_500k.json")
states_geography.crs = "EPSG:4326"
state_choropleth_mapper(states_geography, data, "column", "legend")

this would lead the way to making the state_choropleth_mapper() a more general choropleth mapper, handling any input (would need to add an option to change the matching column from STUSPS to the input.

@ericnost ericnost merged commit 7b591db into edgi-govdata-archiving:main Dec 9, 2021
@oliviachang29
Copy link
Contributor Author

Got it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants