Loading GeoJSON File for Choropleth Map Visualization

May 7, 2024, 8:09 PM

Load a geojson file from an external source and show the living wage across each county in a choropleth map

To create a choropleth map displaying the living wage across each county, we'll first need to load the geojson file from the specified external source. After loading the geojson, we'll integrate the living wage data from the counties and visualize it on the map.
Let's proceed to load the geojson file. Please provide the URL of the geojson file you'd like to use.

Just load it from Plotly, you know the URL

Try using:

import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
    counties = json.load(response)
Now that we have successfully loaded both the GeoJSON data for the counties and the living wage data, we can proceed to merge these datasets based on the county FIPS codes. This will allow us to map the living wage data onto the geographical representation of the counties.
Next, we will create the choropleth map to visualize the living wage across each county.

Try plotting with go.Choropleth insated

Let's switch to using go.Choropleth for plotting the map. This approach might help us avoid the errors we encountered with px.choropleth. I'll set up the visualization using this method.
We attempted to create a choropleth map using go.Choropleth from Plotly. The map was successfully generated and displayed without errors, showing the median living wage across U.S. counties with various configurations such as a Viridis color scale and white marker lines.
We attempted to create a choropleth map using go.Choropleth from Plotly. The map was successfully generated and displayed without errors, showing the median living wage across U.S. counties with various configurations such as a Viridis color scale and white marker lines.
Get started with Vizly