ft-interactive/ministere-interieur-elections-to-insee

Name: ministere-interieur-elections-to-insee

Owner: FT Interactive News

Description: Generates a translation table of government commune to INSEE codes

Created: 2017-04-26 12:34:17.0

Updated: 2017-05-08 21:25:12.0

Pushed: 2017-05-08 17:04:56.0

Homepage: null

Size: 331

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ministère de L'Intérieur Election Geocode to INSEE Translation Table

This repo generates a translation table mapping the weird coding scheme used by the French Ministère de L'Intérieur to the commonly-used INSEE codes predominantly used in geographical software.

Usage:
  1. Install:

    m install ft-interactive/ministere-interieur-elections-to-insee --save
    
  2. Require government-to-insee.json in your code:

    ES6 modules (Dependent upon transpiler/packager being able to import JSON):

    rt * as translationTable from 'ministere-interieur-elections-to-insee';
    

    CommonJS require():

    t translationTable = require('ministere-interieur-elections-to-insee');
    
  3. Check translation table for government code to get corresponding INSEE code:

    t paris_1er_Arrondissement_INSEE = translationTable['75056AR01']; // Returns '75101'
    
Building:

It's inevitable that some boundary changes will occur before the next French election. To rebuild the table, you need to do a few things:

  1. Clone repo:

    t clone https://github.com/ft-interactive/ministere-interieur-elections-to-insee
    
  2. Install dependencies:

    npm:

    m install
    

    Yarn:

    rn install
    
  3. Download the latest versions of the commune and arrondissement shapefiles from: https://www.data.gouv.fr/en/datasets/decoupage-administratif-communal-francais-issu-d-openstreetmap/

You want the latest “Export simple” and “Arrondissements Municipaux” files.

  1. Move the .shp and .dbf files from each zipfile into data/

  2. Copy referencePR/listeregdptcom.xml from http://elections.interieur.gouv.fr/ into data/

  3. Create the JSON sources from the data:

m run convert-communes-shp && npm run convert-arrondissements-shp && npm run create-sources
  1. Generate the translation table:
m run create-table
Notes:
  1. There is also a CSV version generated at code-translation-table.csv in this repo.
  2. The generation process compares the name strings using Dice's coefficient and reports a warning when this is less than 0.4. Any such results are saved in data/possibly-dubious-codes.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.