France Choropleth map with Leaflet and d3.js
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
.gitignore
france.css
france.js
index.html
readme.gif
readme.md
robots.txt

readme.md

France Choropleth

This repository shows a complete choropleth map, made with Leaflet and d3.js. It provides a full towns search engine (thanks to Awesomplete), legend generation, and layer support. See the demo.

Choropleth demo

Usage

After having created a Leaflet map object, use france() to create a new choropleth. You can provide many layers:

var choropleth = new france(map, layer1[, layer2, layer3])

A layer is defined as follows:

{
  stat: 'filename',                            // column name in csv file
  file: '/path/to/file.csv',                   // url to csv file
 title: ['Layer title','Date'],                // legend title (and date)
domain: [x_0, x_1, ..., x_n],                  // values stops and limits...
 range: ['color_0','color_1', ...,'color_n'],  // ... and associated colors
  unit: 'unit name',                           // prefix after numbers (%, €)
  plus: ''                                     // suffix before numbers (+)
}

Requirement

The javascript code requires Leaflet, d3js, Awesomplete and TopoJSON. The makefile and _generate.py need python3, pandas and xlrd libraries.

Administrative levels

‘Communes’ are the smallest administrative level in France. Although their high number (more than 36.000) is quite satisfying for spatial statistics purposes, users would have to download a 10MB file and to wait more than 20 seconds for the rendering. On the other side, there is only 2.000 ‘cantons’ (higher administrative level), which is not quite enough.

Keeping communes with more than 1.000 people, or with more than 75 people per square kilometre, and showing cantons for the smaller communes, gives us a 2.9MB file and a good looking map.

License

Contents and codes are published under the MIT license; you are free to reuse them, but please keep a link to sylvaindurand.org.

Spatial data is provided by OpenStreetMap project (© OpenStreetMap contributor), and licensed under ODbL. Tiles are kindly provided by CartoCDN and released under Creative Commons Attribution (CC BY 3.0).

Statistics data is provided by the French National Institute for Statistic INSEE with the ‘code officiel geographique’ and ‘chiffres clefs’ databases (conditions).