Swirrl / d3-choropleth-demo

hacky d3 prototype/demo choropleth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

D3 choropleth demo.

Just a hacky d3 demo choropleth. A long way from production quality!

Get boundaries as geojson

e.g. from ONS geo portal

transform with mapshaper

Mapshaper

e.g.

mapshaper -i districts.geojson \
-proj from=EPSG:27700 crs=EPSG:4326 \
-simplify 1% \
-o precision=0.0001 format=geojson mapshaped-districts.geojson

Get a 1D CSV slice of data from somewhere.

e.g. From NOMIS:

e.g Jobseeker's Allowance by age and duration

Filtered CSV.

View map.html in a browser

You'll need to run this on a webserver for it to work. e.g. python3 -m http.server.

http://localhost:8080/map.html

example screenshot

Disclaimers / TODO:

  • The code isn't very idiomatic d3: just proving the concept.
  • Doesn't consider different binning strategies - this is just hardcoded with little thought for now.
  • Map needs a legend / title
  • Doesn't consider printing to PDF yet.

Data licence

Source: Office for National Statistics licensed under the Open Government Licence v.3.0

About

hacky d3 prototype/demo choropleth

License:MIT License


Languages

Language:HTML 100.0%