How to create a choropleth map

I’m trying to make a choropleth map as part of my Data Visualizations Projects, but I can’t seem to figure out how. I’m able to access the data from both JSON links but I have no idea how to use the data to render the map. I tried researching how but I just feel more confused. If anybody has any resources about this or could help me, it would be greatly appreciated.

4 Likes

d3 has a method called geopath() that will draw geographic shapes using data in the form of a GeoJSON object. However, the data in the JSON link is in a TopoJSON format.

The TopoJSON library has a utility to extract the data you want from the TopoJSON file (just county borders, for example) and convert that back into a GeoJSON object. Once it’s in GeoJSON format, you can feed into d3’s .data() method like normal. Then you’ll have to use the d3.geopath method to actually draw the borders.

I wish the description of the challenge was a little more clear, I was tearing my hair out like you until I dove into the source code of the example project to find out that using TopoJSON was the key.

6 Likes

Thanks so much, @NMorin86 Yes, I really wish the description was clearer.