Giter Site home page Giter Site logo

etalab / geohisto Goto Github PK

View Code? Open in Web Editor NEW
28.0 17.0 1.0 27.74 MB

[UNMAINTAINED] Historic information for French regions, counties, overseas collectivities and towns based on INSEE and Wikipedia data, exported as (re)usable CSV files.

License: Other

Python 100.00%
history towns french counties regions insee opendata graph communes departements

geohisto's Introduction

⚠️ Not maintained anymore. See https://github.com/etalab/decoupage-administratif

GeoHisto

Historic information for French regions, counties, overseas collectivities and towns based on INSEE and Wikipedia data, exported as (re)usable CSV files.

It might be useful if you have to deal with redirections and is in use by the geozones project to feed data.gouv.fr.

Usage

If you’re only interested in generated data, check out the exports folder which contains CSV files related to intercommunalities, regions, counties, overseas collectivities and towns. There is a dedicated documentation at these places.

Sources

Source files are coming from the INSEE downloads page which allows to retrieve information related to the “Code officiel géographique 2017”. We’re using the list of existing towns and their history which are both available within the sources folder.

Additionaly, files containing the population for almost all towns has been computed too in the sources folder. They are coming from a XLS dataset provided by INSEE, manually completed with Wikipedia data for Lyon and Marseille districts, and converted into CSV.

Intercommunalities source files are fully documented into their folder.

Development

The project only requires click dependency (you can install it with pip install -r requirements.txt within a virtualenv but YMMV), you have to run it with Python 3 though:

$ python -m geohisto

Note that it takes about 7 minutes to generate the towns export.

Optionally, you can specify a date to only export towns valid at that given date:

$ python -m geohisto --at-date 2016-01-01

It will be generated within the exports/communes/ folder with an explicit name.

To also generate the intercommunalities, you need to add the --intercommunalities flag.

$ python -m geohisto --intercommunalities

The whole process takes about one hour and a half to generate both towns and intercommunalities exports (on a core i7 with 16Gb RAM). You may add some extra output to see the progress by setting the verbosity to debug:

$ python -m geohisto --intercommunalities -v debug

Tests

If you plan to contribute, you have to install pytest and launch the test suite:

$ python -m pytest tests

Note that the duration of the whole test suite run is about 5 minutes.

That's why you would probably prefer to run a particular test:

$ python -m pytest tests/test_actions.py::test_change_name

Licenses

See LICENSE.md file for code and produced data.

geohisto's People

Contributors

davidbgk avatar jdesboeufs avatar noirbizarre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

rhanka

geohisto's Issues

Towns with only inactive successors

Many towns have an end_datetime but inactive successors.
1319 town records may be in this situation.

Example (Arlod):

cat data/towns.csv | grep COM01033@1942-01-01

COM01018@1942-01-01,01018,1942-01-01 00:00:00,1970-12-31 23:59:59,Arlod,COM01033@1942-01-01,,DEP01@1860-07-01,NULL,310
COM01033@1942-01-01,01033,1942-01-01 00:00:00,1956-10-18 23:59:59,Bellegarde,COM01033@1956-10-19,COM01018@1942-01-01,DEP01@1860-07-01,NULL,100
COM01033@1956-10-19,01033,1956-10-19 00:00:00,9999-12-31 23:59:59,Bellegarde-sur-Valserine,,COM01033@1942-01-01;COM01126@1942-01-01,DEP01@1860-07-01,11644,0

Handle special cases manually

Given that some cases are harder to solve algorithmically than manually, handle those with a special post-treatment of the regular processing.

Problem in EPCI data

Detailed Description

We saw a problem with geohisto/exports/epci/epci.csv :
fr:epci:243301223 has 2001 to 2005 and 2010 to 2017 data but 2006 to 2009 data are missing.

However, these data exist in geohisto/sources/epci/*.csv used by scripts to generate geohisto/exports/epci/epci.csv.

Furthermore, successors and ancestors point to some EPCI outside the department and sometimes very far ...

We did not appraise the script to see where these errors came from.

Notes

We are french. You too, I think. Why are we obliged to communicate in English ?

20 cases of invalid successors

TOWN <Town (COM09092@1942-01-01): Cazenave-Serres-et-Allens from 1942-01-01 to 1973-03-31 with successors COM09092@1981-01-01;COM09306@1958-10-22> https://www.insee.fr/fr/metadonnees/cog/commune/COM09092-Cazenave-Serres-et-Allens
SUCC <Town (COM09092@1981-01-01): Cazenave-Serres-et-Allens from 1981-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM09092-Cazenave-Serres-et-Allens
TOWN <Town (COM2A325@1942-01-01): Tivolaggio from 1942-01-01 to 1974-03-31 with successors COM2A249@1976-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM2A325-Tivolaggio
SUCC <Town (COM2A249@1976-01-01): Propriano from 1976-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM2A249-Propriano
TOWN <Town (COM2B076@1942-01-01): Cassano from 1942-01-01 to 1972-12-31 with successors COM2B167@1976-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM2B076-Cassano
SUCC <Town (COM2B167@1976-01-01): Montegrosso from 1976-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM2B167-Montegrosso
TOWN <Town (COM27688@1942-01-01): Villalet from 1942-01-01 to 2015-12-31 with successors COM27693@1972-10-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM27688-Villalet
SUCC <Town (COM27693@1972-10-01): Sylvains-les-Moulins from 1972-10-01 to 2015-12-31 with successors COM27693@2016-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM27693-Sylvains-les-Moulins
TOWN <Town (COM28042@1942-01-01): Bleury from 1942-01-01 to 2011-12-31 with successors COM28361@2016-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM28042-Bleury
SUCC <Town (COM28361@2016-01-01): Saint-Symphorien-le-Château from 2016-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM28361-Saint-Symphorien-le-Château
TOWN <Town (COM28361@1942-01-01): Saint-Symphorien from 1942-01-01 to 1969-01-05 with successors COM28361@2016-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM28361-Saint-Symphorien
SUCC <Town (COM28361@2016-01-01): Saint-Symphorien-le-Château from 2016-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM28361-Saint-Symphorien-le-Château
TOWN <Town (COM28297@1942-01-01): Pézy from 1942-01-01 to 2015-12-31 with successors COM28383@1942-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM28297-Pézy
SUCC <Town (COM28383@1942-01-01): Theuville from 1942-01-01 to 2015-12-31 with successors COM28383@2016-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM28383-Theuville
TOWN <Town (COM53111@1942-01-01): La Haie-Traversaine from 1942-01-01 to 1971-12-31 with successors COM53111@1987-01-01;COM53003@1972-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM53111-La Haie-Traversaine
SUCC <Town (COM53111@1987-01-01): La Haie-Traversaine from 1987-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM53111-La Haie-Traversaine
TOWN <Town (COM55386@1942-01-01): Nonsard from 1942-01-01 to 1982-12-31 with successors COM55245@1973-01-01;COM55386@1983-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM55386-Nonsard
SUCC <Town (COM55245@1973-01-01): Madine from 1973-01-01 to 1982-12-31 with successors COM55245@1983-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM55245-Madine
TOWN <Town (COM64031@1942-01-01): Arancou from 1942-01-01 to 1972-12-31 with successors COM64031@1977-11-15;COM64113@1973-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM64031-Arancou
SUCC <Town (COM64031@1977-11-15): Arancou from 1977-11-15 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM64031-Arancou
TOWN <Town (COM76355@1942-01-01): Héricourt-en-Caux from 1942-01-01 to 1973-04-09 with successors COM76355@1976-10-29;COM76355@1973-04-10> https://www.insee.fr/fr/metadonnees/cog/commune/COM76355-Héricourt-en-Caux
SUCC <Town (COM76355@1976-10-29): Héricourt-en-Caux from 1976-10-29 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM76355-Héricourt-en-Caux
TOWN <Town (COM77166@1942-01-01): Écuelles from 1942-01-01 to 2014-12-31 with successors COM77316@2016-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM77166-Écuelles
SUCC <Town (COM77316@2016-01-01): Moret Loing et Orvanne from 2016-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM77316-Moret Loing et Orvanne
TOWN <Town (COM22103@1970-12-07): Langrolay-sur-Rance from 1970-12-07 to 1973-03-14 with successors COM22213@1942-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM22103-Langrolay-sur-Rance
SUCC <Town (COM22213@1942-01-01): Plouër from 1942-01-01 to 1949-10-29 with successors COM22213@1949-10-30> https://www.insee.fr/fr/metadonnees/cog/commune/COM22213-Plouër
TOWN <Town (COM52427@1972-09-01): Robert-Magny-Laneuville-à-Rémy from 1972-09-01 to 2011-12-31 with successors COM52331@2016-01-01;COM52427@2012-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM52427-Robert-Magny-Laneuville-à-Rémy
SUCC <Town (COM52331@2016-01-01): La Porte du Der from 2016-01-01 to 9999-12-31 with successors > https://www.insee.fr/fr/metadonnees/cog/commune/COM52331-La Porte du Der
TOWN <Town (COM55273@1983-01-01): Lamarche-en-Woëvre from 1983-01-01 to 1983-01-01 with successors COM55386@1942-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM55273-Lamarche-en-Woëvre
SUCC <Town (COM55386@1942-01-01): Nonsard from 1942-01-01 to 1982-12-31 with successors COM55245@1973-01-01;COM55386@1983-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM55386-Nonsard
TOWN <Town (COM68006@2016-01-01): Ammerzwiller from 2016-01-01 to 2016-01-01 with successors COM68006@2016-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM68006-Ammerzwiller
SUCC <Town (COM68006@2016-01-01): Ammerzwiller from 2016-01-01 to 2016-01-01 with successors COM68006@2016-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM68006-Ammerzwiller
TOWN <Town (COM77316@2015-01-01): Moret-sur-Loing from 2015-01-01 to 2015-01-01 with successors COM77316@2015-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM77316-Moret-sur-Loing
SUCC <Town (COM77316@2015-01-01): Moret-sur-Loing from 2015-01-01 to 2015-01-01 with successors COM77316@2015-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM77316-Moret-sur-Loing
TOWN <Town (COM28361@2012-01-01): Saint-Symphorien-le-Château from 2012-01-01 to 2012-01-01 with successors COM28361@2012-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM28361-Saint-Symphorien-le-Château
SUCC <Town (COM28361@2012-01-01): Saint-Symphorien-le-Château from 2012-01-01 to 2012-01-01 with successors COM28361@2012-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM28361-Saint-Symphorien-le-Château
TOWN <Town (COM49092@2013-01-01): Chemillé from 2013-01-01 to 2013-01-01 with successors COM49092@2013-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM49092-Chemillé
SUCC <Town (COM49092@2013-01-01): Chemillé from 2013-01-01 to 2013-01-01 with successors COM49092@2013-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM49092-Chemillé
TOWN <Town (COM49101@2013-01-01): Clefs from 2013-01-01 to 2013-01-01 with successors COM49101@2013-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM49101-Clefs
SUCC <Town (COM49101@2013-01-01): Clefs from 2013-01-01 to 2013-01-01 with successors COM49101@2013-01-01> https://www.insee.fr/fr/metadonnees/cog/commune/COM49101-Clefs

See tests/test_output_validity.py:test_successors_are_valid for details.

Error with Freigné for 2018/01/01 export attempt

I'm trying to generate a version of the French communes for 2018 with this tool. I added new files "France2018" and "historiq2018" from Insee + the file "2018.csv" for EPCI in the sources folder. Also, I redirected filenames to the 2018 files in the loaders functions.

And I get an error (of course ahah). I don't understand how it happens after reading of the functions.
This is the error :

C:\Users\rfr\Documents_py\geohisto-master>python -m geohisto
Loading towns
Loading history
Loading populations
Loading counties
Computing history from actions
Record(depcom='44225', mod=331, eff=datetime.datetime(2018, 1, 1, 0, 0), nccoff='Freigné', nccanc='', comech='44180', dep='44', com='225', depanc='', last=None, effdate=datetime.date(2018, 1, 1))
Traceback (most recent call last):
File "C:\Python37\lib\runpy.py", line 193, in run_module_as_main
"main", mod_spec)
File "C:\Python37\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\rfr\Documents_py\geohisto-master\geohisto_main
.py", line 6
6, in
main()
File "C:\Python37\lib\site-packages\click\core.py", line 716, in call
return self.main(*args, **kwargs)
File "C:\Python37\lib\site-packages\click\core.py", line 696, in main
rv = self.invoke(ctx)
File "C:\Python37\lib\site-packages\click\core.py", line 889, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Python37\lib\site-packages\click\core.py", line 534, in invoke
return callback(*args, **kwargs)
File "C:\Python37\lib\site-packages\click_log\core.py", line 94, in wrapper
return f(*args, **kwargs)
File "C:\Users\rfr\Documents_py\geohisto-master\geohisto_main
.py", line 3
4, in main
compute(towns, history_list)
File "C:\Users\rfr\Documents_py\geohisto-master\geohisto\actions.py", line 39
7, in compute
raise e
File "C:\Users\rfr\Documents_py\geohisto-master\geohisto\actions.py", line 39
4, in compute
ACTIONS.get(record.mod, lambda a, b: a)(towns, record)
File "C:\Users\rfr\Documents_py\geohisto-master\geohisto\actions.py", line 19
6, in deletion
modification=record.mod
File "C:\Users\rfr\Documents_py\geohisto-master\geohisto\models.py", line 216
, in generate
raise Exception(msg)
Exception: You cannot set 2018-01-01 00:00:00 as a start date and 2017-12-31 23:59:59.999999 as an end date for Town <Town (fr:commune:44225@2018-01-01): Freigné from 2018-01-01 to 2018-01-01 with successors and mod 0>.

I found the modification that poses problem on the historical file (Freigné, mod 331) but I don't understand what is happening (from a technical and territorial point of view), if you can enlighten me?

Thks for help and the tool!

Chisa, Butry-sur-Oise, Toussus-le-Noble: unknown successor

Chisa has a successor which is not in the dataset. Should be Corse splitting related.

cat data/towns.csv | grep COM2B366@1976-01-01

COM20366@1947-04-12,20366,1947-04-12 00:00:00,1975-12-31 23:59:59,Chisa,COM2B366@1976-01-01,,DEP20@1860-07-01,NULL,410

A side-effect is an erroneous id for the second occurrence of Chisa.

cat data/towns.csv | grep Chisa

COM20366@1942-01-01,20366,1976-01-01 00:00:00,9999-12-31 23:59:59,Chisa,,,DEP20@1860-07-01,NULL,200
COM20366@1947-04-12,20366,1947-04-12 00:00:00,1975-12-31 23:59:59,Chisa,COM2B366@1976-01-01,,DEP20@1860-07-01,NULL,410

Oudon case

Before new-start:

➜  communes grep 14624 towns.csv 
--,14624,Saint-Martin-de-Fresnay,1973-01-01,2020-01-01,NULL
<-,14624,Oudon,1973-01-01,1973-01-01,NULL

Now:

→ cat exports/towns/towns.csv | grep 14624               33ms
451551942-01-019999-01-01,45155,Gien,1942-01-01,9999-01-01,,,14624,0
146241973-01-019999-01-01,14624,Oudon,1973-01-01,9999-01-01,,146241942-01-011973-01-01;140101942-01-011973-01-01;140671942-01-011973-01-01;142341942-01-011973-01-01;142951942-01-011973-01-01;143141942-01-011973-01-01;143631942-01-011973-01-01;144471942-01-011973-01-01;144721942-01-011973-01-01;146971942-01-011973-01-01,NULL,0
146241942-01-011973-01-01,14624,Saint-Martin-de-Fresnay,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,110
140101942-01-011973-01-01,14010,Ammeville,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
140671942-01-011973-01-01,14067,Berville,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
142341942-01-011973-01-01,14234,Écots,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
142951942-01-011973-01-01,14295,Garnetot,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
143141942-01-011973-01-01,14314,Grandmesnil,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
143631942-01-011973-01-01,14363,Lieury,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
144471942-01-011973-01-01,14447,Montpinçon,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
144721942-01-011973-01-01,14472,Notre-Dame-de-Fresnay,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330
146971942-01-011973-01-01,14697,Tôtes,1942-01-01,1973-01-01,146241973-01-019999-01-01,,NULL,330

See http://www.insee.fr/fr/methodes/nomenclatures/cog/fichecommunale.asp?codedep=14&codecom=624

Sylvains-Lès-Moulins case: it’s its own successor

Detailed Description

The city has itself as successor and the new city isn’t referenced.

Maybe it is caused by a double change (merge and name change) ?

Current result

grep "^COM27693@1972-10-01" towns.csv 
COM27693@1972-10-01,27693,1972-10-01 00:00:00,2015-12-31 23:59:59,Sylvains-les-Moulins,COM27693@1972-10-01,COM27178@1942-01-01;COM27688@1942-01-01;COM27693@1942-01-01;COM27693@1972-10-01,DEP27@1860-07-01,1207,311

A total of 7 towns have the same problem:

grep "^\(COM[0-9]\{5\}@[0-9-]\{10\}\),.*,\1," towns.csv

Correct result

COM27693@1972-10-01,27693,1972-10-01 00:00:00,2015-12-31 23:59:59,Sylvains-les-Moulins,COM27693@2016-01-01,COM27178@1942-01-01;COM27688@1942-01-01;COM27693@1942-01-01;COM27693@2016-01-01,DEP27@1860-07-01,1207,311
COM27693@2016-01-01,27693,2016-01-01 00:00:00,9999-12-31 23:59:59,Sylvains-Lès-Moulins,,COM27693@1972-10-01,DEP27@1860-07-01,1207,321

Link to INSEE page

https://www.insee.fr/fr/metadonnees/cog/commune/COM27693-sylvains-les-moulins

Other with the same problem:

Towns with same INSEE code at the same moment

We have two town entries with the same code at the same moment.

Command

cat towns.csv | grep 76355

Output

COM76355@1976-10-29,76355,1976-10-29 00:00:00,9999-12-31 23:59:59,Héricourt-en-Caux,,COM76355@1942-01-01,DEP76@1860-07-01;DEP76@1955-01-18,936,230
COM76355@1973-04-10,76355,1973-04-10 00:00:00,9999-12-31 23:59:59,Rocquefort-sur-Héricourt,,COM76531@1942-01-01;COM76355@1942-01-01,DEP76@1860-07-01;DEP76@1955-01-18,1247,120

Code INSEE Communes à Mayotte avant 2008

Detailed Description

Les codes INSEE des villes à Mayotte sont présents dans l'export d'historique des communes fourni par geohisto avec les codes INSEE en 976xx et des dates de début en 1942.
La date de début ne semble pas correspondre à la réalité puisqu’avant 2008 les codes INSEE des communes à Mayotte étaient en 985xx.

Par exemple ACOUA était codé en 98501 et a basculé en 97601.
Ne devrait-on pas retrouver le code 985xx de 1942 à fin 2007 puis basculer en 976xx?
Ou alors est-ce lié au statut des territoires puis des collectivités d'Outre Mer qui justifie ce choix?

Je vois par exemple sur la page http://infocentre.pleiade.education.fr/bcn/workspace/viewTable/n/N_COMMUNE que sur leur référentiel des communes on retrouve les anciennes versions du codes et la nouvelle version du code.

Current result

Correct result

Link to INSEE page

Mauvezin-sur-Gupie - fr:commune:47163@2003-02-03 n'a pas d'ancêtre

Detailed Description

La commune Mauvezin-sur-Gupie (47163) a été rattachée à la commune de Marmande en 1972 et a retrouvé son autonomie le 3 février 2003.
Dans geohisto on a bien la commune avant (fr:commune:47163@1942-01-01) et la commune après (fr:commune:47163@2003-02-03) mais le graphe ne retrace pas les évolutions:

  1. la commune de Marmande (fr:commune:47157@1942-01-01) n'est pas modifiée
  2. fr:commune:47163@2003-02-03 n'a pas d'ancêtre

Current result

  fr:commune:47163@1942-01-01:
    insee_code: 47163
    start_datetime: 1942-01-01 00:00:00
    end_datetime: 1972-10-31 23:59:59
    name: Mauvezin-sur-Gupie
    successors:
      - fr:commune:47157@1942-01-01
    ancestors:
    parents:
      - fr:departement:47@1860-07-01
    population: 567
    insee_modification: "Rétablissement (210)"
  fr:commune:47157@1942-01-01:
    insee_code: 47157
    start_datetime: 1942-01-01 00:00:00
    end_datetime: 9999-12-31 23:59:59
    name: Marmande
    successors:
    ancestors:
      - fr:commune:47163@1942-01-01
    parents:
      - fr:departement:47@1860-07-01
    population: 18028
    insee_modification: "Commune se séparant (230)"
  fr:commune:47163@2003-02-03:
    insee_code: 47163
    start_datetime: 2003-02-03 00:00:00
    end_datetime: 9999-12-31 23:59:59
    name: Mauvezin-sur-Gupie
    successors:
    ancestors:
    parents:
      - fr:departement:47@1860-07-01
    population: 567
    insee_modification: " (0)"

Correct result

La commune de Marmande devrait correspondre à 3 versions successives:

  • fr:commune:47157@1942-01-01
  • fr:commune:47157@1973-11-01
  • fr:commune:47157@2003-02-03

fr:commune:47163@2003-02-03 devrait avoir pour ancêtre fr:commune:47157@1973-11-01

Link to INSEE page

https://www.insee.fr/fr/metadonnees/cog/commune/COM47163-mauvezin-sur-gupie

Lamarche-en-Woëvre case

Current:

→ cat exports/towns/towns.csv | grep Lamarche            53ms
213371942-01-019999-01-01,21337,Lamarche-sur-Saône,1942-01-01,9999-01-01,,,1307,0
882581942-01-019999-01-01,88258,Lamarche,1942-01-01,9999-01-01,,,983,0
883071942-01-019999-01-01,88307,Mont-lès-Lamarche,1942-01-01,9999-01-01,,,102,0
552731942-01-011983-01-01,55273,Lamarche-en-Woëvre,1942-01-01,1983-01-01,552451973-01-011983-01-01,,NULL,330
552731983-01-019999-01-01,55273,Lamarche-en-Woëvre,1983-01-01,9999-01-01,,552451973-01-011983-01-01,NULL,330
553861983-01-019999-01-01,55386,Nonsard-Lamarche,1983-01-01,9999-01-01,,553861942-01-011973-01-01;552451973-01-011983-01-01;552451973-01-011983-01-01,200,330

See http://www.insee.fr/fr/methodes/nomenclatures/cog/fichecommunale.asp?codedep=55&codecom=273

Questions L'Oudon et défusions

Bonjour,

Tout d'abord merci pour ce travail sur les géographies communales. Je travaille moi-même sur ces questions depuis une petite année et ai pu développer quelques petits outils pour pouvoir transformer des bases de données d'un COG à un autre. Je suis donc enthousiaste de voir qu'Etalab s'est positionné sur ces questions et je compte donc regarder si vos résultats concordent avec mes propres conclusions.

  1. Ma première question concerne la commune de L'Oudon dans le Calvados (14). Il me semble que dans towns.csv, vous identifiez la commune de l'Oudon comme étant codée "14472" du 1973-01-01 00:00:00 au 2016-12-31 23:59:59. Or, en réalisant le même type de travail de mon côté, j'avais noté qu'elle était codée tout d'abord "14697" puis avait changé de code devenant "14472" à partir du 07/01/2014 suite à un transfert de chef lieu (modification Insee = 500) cf. lien ci-dessous : 07/01/2014 : Transfert de chef-lieu de L'Oudon de Tôtes à Notre-Dame-de-Fresnay.
    https://www.insee.fr/fr/metadonnees/cog/commune/COM14472-oudon

  2. Une deuxième question concerne deux éléments que j'avais pris en compte moi-même dans mes données et qui semblent être également identifiés sur le site de l'Insee mais qui ne semblent pas être identifiés dans towns.csv. Il s'agit des éléments suivants :

https://www.insee.fr/fr/metadonnees/cog/commune/COM55409-pretz
01/01/1973 : Pretz (55409) est rattachée à Triaucourt-en-Argonne (55517) (fusion association) qui devient Seuil-d'Argonne (55517).
=> Ligne COM55409@1942-01-01 me semble fausse car Pretz est notée comme existant jusqu'en 1989 au lieu de 1973

https://www.insee.fr/fr/metadonnees/cog/commune/COM73024-avanchers
18/07/1972 : Les Avanchers (73024) est rattachée à Aigueblanche (73003) pour donner Aigueblanche (73003) (fusion association).
=> Événement qui ne semble pas être présent dans la table towns

  1. Une troisième question concerne la compréhension des variables "ancestors" et "successors" en cas de défusion. Prenons l'exemple de la défusion de Bois-Guillaume-Bihorel (76108) en Bois-Guillaume (76108) et Bihorel (76095) au 01/01/2014.
    Je ne comprends pas pourquoi la ligne identifiée COM76095@2014-01-01 (Bihorel) ne contient pas comme ancestors COM76108@2012-01-01 (Bois-Guillaume-Bihorel).
    Et pourquoi la ligne COM76108@2012-01-01 (Bois-Guillaume-Bihorel) ne contient comme successors que COM76108@2014-01-01 (Bois-Guillaume) mais pas COM76095@2014-01-01 (Bihorel).
    COM76108@2014-01-01 (Bois-Guillaume) contient bien, lui, comme ancestors COM76108@2012-01-01 (Bois-Guillaume-Bihorel) .
    Et cette situation semble être semblable dans tous les cas de défusions. Or, sans cette information, il ne m'a pas pouvoir voir apparaître dans votre table l'évènement indiqué au lien suivant : 01/01/2014 : Bois-Guillaume-Bihorel devient Bois-Guillaume suite au rétablissement de Bihorel.
    https://www.insee.fr/fr/metadonnees/cog/commune/COM76108-bois-guillaume-bihorel

Que pensez-vous de ces deux points ?

Merci pour vos réponses qui me permettront peut-être de voir si je peux intégrer votre travail dans mes outils.

Kim

Dates overlap

We need to introduce timestamps to avoid overlaps on start/end dates. One second of uncertainty is probably enough in our case.

Town stop and start but with no changes

Here is a town with a successor but without any visible change.

But according to the modification code and the INSEE website, the town should have been renamed from Ville-aux-Bois to La-Ville-aux-Bois.

cat towns.csv | grep COM10411@1942-01-01
COM10411@1942-01-01,10411,1942-01-01 00:00:00,1957-01-12 23:59:59,Ville-aux-Bois,COM10411@1957-01-13,,DEP10@1860-07-01,NULL,100
COM10411@1957-01-13,10411,1957-01-13 00:00:00,9999-12-31 23:59:59,Ville-aux-Bois,,COM10411@1942-01-01,DEP10@1860-07-01,NULL,0

Erreurs sur code 330 (Pretz, Les Avanchers)

https://www.insee.fr/fr/metadonnees/cog/commune/COM55409-pretz
01/01/1973 : Pretz (55409) est rattachée à Triaucourt-en-Argonne (55517) (fusion association) qui devient Seuil-d'Argonne (55517).
=> Ligne COM55409@1942-01-01 me semble fausse car Pretz est notée comme existant jusqu'en 1989 au lieu de 1973

https://www.insee.fr/fr/metadonnees/cog/commune/COM73024-avanchers
18/07/1972 : Les Avanchers (73024) est rattachée à Aigueblanche (73003) pour donner Aigueblanche (73003) (fusion association).
=> Événement qui ne semble pas être présent

Merci @antuki

Comparison with INSEE towns file

COG file: 2016
Geohisto file: 2016

Arrondissements are ignored

35887 codes in Geohisto
35885 codes in COG
Town 14624 found in geohisto but not in COG: Oudon
Town 20366 found in geohisto but not in COG: Chisa
Town 27255 found in geohisto but not in COG: Fontenay
Town 28361 found in geohisto but not in COG: Saint-Symphorien-le-Château
Town 44060 found in geohisto but not in COG: Le Fresne-sur-Loire
Town 49101 found in geohisto but not in COG: Clefs
Town 52427 found in geohisto but not in COG: Robert-Magny
Town 78692 found in geohisto but not in COG: Butry-sur-Oise
Town 14472 found in COG but not in Geohisto: Oudon
Town 27693 found in COG but not in Geohisto: Sylvains-Lès-Moulins
Town 28383 found in COG but not in Geohisto: Theuville
Town 78620 found in COG but not in Geohisto: Toussus-le-Noble
Town 95120 found in COG but not in Geohisto: Butry-sur-Oise
Town 2B366 found in COG but not in Geohisto: Chisa

Repository: https://github.com/jdesboeufs/geohisto-compare

Claunay case

Before new-start:

➜  communes grep Claunay towns.csv 
<-,86079,La Claunay-en-Loudun,1942-01-01,1967-11-20,NULL
<-,86079,La Claunay-en-Loudun,1967-11-20,1972-04-01,NULL
➜  communes grep Roche-Rigault towns.csv 
--,86079,La Roche-Rigault,1972-04-01,2020-01-01,535

Now:

→ cat exports/towns/towns.csv | grep Claunay
860791942-01-011972-04-01,86079,Claunay-en-Loudun,1942-01-01,1972-04-01,860791972-04-011967-11-20,,NULL,110
860791967-11-201972-04-01,86079,Claunay-en-Loudun,1967-11-20,1972-04-01,860791972-04-019999-01-01,,NULL,110
→ cat exports/towns/towns.csv | grep Roche-Rigault
EMPTY

Missing town for INSEE code 14697 starting on year 2003

Detailed Description

Town with INSEE code 14697 seams to have disappear since 2003 but in fact it's a very special case were INSEE code has been reused and inverted with the "chef-lieu".

See #53 (comment) to have context where it has been detected

It seams to have something to do with https://github.com/etalab/geohisto/blob/master/geohisto/specials.py#L432-L459 which doesn't handle the 14697 INSEE code

Link to INSEE page

Communes appartenant à plusieurs EPCI en même temps

Bonjour,

J'ai tenté de chaîner les différents types d'objets dans geohisto, et je rencontre quelques difficultés avec les EPCI.

Par exemple lorsque je travaille sur la commune fr:commune:54084@1952-11-14, je découvre qu'elle est référencées dans plusieurs EPCI actives.
Je m'attendais à ce qu'une seule EPCI soit active en date d'aujourd'hui.

L'objet commune (adapté par mon script) :

{ id: 'fr:commune:54084@1952-11-14',
     insee_code: '54084',
     name: 'Mont-Bonvillers',
     ancestors: [ 'fr:commune:54084@1942-01-01' ],
     parents:
      [ 'fr:departement:54@1871-09-07',
        'fr:epci:245403003@2002-01-01',
        'fr:epci:245400825@2003-01-01',
        'fr:epci:245400825@2004-01-01',
        'fr:epci:245400825@2005-01-01',
        'fr:epci:245400825@2006-01-01',
        'fr:epci:245400825@2007-01-01',
        'fr:epci:245400825@2008-01-01',
        'fr:epci:245400825@2009-01-01',
        'fr:epci:245400825@2010-01-01',
        'fr:epci:245400825@2011-01-01',
        'fr:epci:245400825@2012-01-01',
        'fr:epci:245400825@2013-01-01',
        'fr:epci:245400825@2014-01-01',
        'fr:epci:245400825@2015-01-01',
        'fr:epci:245400825@2016-01-01',
        'fr:epci:200070290@2017-01-01' ],
     population: 979,
     insee_modification: '0',
     start_date: '1952-11-14',
     kind: 'commune' }

Les EPCI "parentes" actives en date d'aujourd'hui :

[ 'fr:epci:245400825@2005-01-01',
  'fr:epci:245400825@2006-01-01',
  'fr:epci:245400825@2007-01-01',
  'fr:epci:245400825@2008-01-01',
  'fr:epci:245400825@2009-01-01',
  'fr:epci:245400825@2010-01-01',
  'fr:epci:245400825@2011-01-01',
  'fr:epci:245400825@2012-01-01',
  'fr:epci:245400825@2013-01-01',
  'fr:epci:245400825@2014-01-01',
  'fr:epci:245400825@2015-01-01',
  'fr:epci:245400825@2016-01-01',
  'fr:epci:200070290@2017-01-01' ]
Error: Multiple parents are matching

Normalement seule la dernière devrait l'être, et je valide par connaissance du terrain, j'y suis en ce moment même :)

Erreurs sur code 210 et successeurs (Bois-Guillaume/Bihorel)

Prenons l'exemple de la défusion de Bois-Guillaume-Bihorel (76108) en Bois-Guillaume (76108) et Bihorel (76095) au 01/01/2014.
Je ne comprends pas pourquoi la ligne identifiée COM76095@2014-01-01 (Bihorel) ne contient pas comme ancestors COM76108@2012-01-01 (Bois-Guillaume-Bihorel).
Et pourquoi la ligne COM76108@2012-01-01 (Bois-Guillaume-Bihorel) ne contient comme successors que COM76108@2014-01-01 (Bois-Guillaume) mais pas COM76095@2014-01-01 (Bihorel).
COM76108@2014-01-01 (Bois-Guillaume) contient bien, lui, comme ancestors COM76108@2012-01-01 (Bois-Guillaume-Bihorel) .
Et cette situation semble être semblable dans tous les cas de défusions. Or, sans cette information, il ne m'a pas pouvoir voir apparaître dans votre table l'évènement indiqué au lien suivant : 01/01/2014 : Bois-Guillaume-Bihorel devient Bois-Guillaume suite au rétablissement de Bihorel.
https://www.insee.fr/fr/metadonnees/cog/commune/COM76108-bois-guillaume-bihorel

Merci @antuki

La région Centre-Val de Loire a changé de nom par la loi du 16 janvier 2015

Avant la loi du 16 janvier 2015, la région s'appelait "Centre".
La loi a été publiée au JO du 17/1/2015. Je suppose donc qu'elle s'applique à compter du 18/1/2015.

Detailed Description

décomposer en 2 objets se succédant

Current result

fr:region:24@1970-01-09,24,1970-01-09 00:00:00,9999-12-31 23:59:59,Centre-Val de Loire,,,2570546,39151,FR24,fr:commune:45234@1942-01-01,https://fr.wikipedia.org/wiki/Centre-Val_de_Loire

Correct result

fr:region:24@1970-01-09;24;1970-01-09 00:00:00;2015-01-17 23:59:59;Centre;fr:region:24@2015-01-18;;2570546;39151;FR24;fr:commune:45234@1942-01-01;https://fr.wikipedia.org/wiki/Centre-Val_de_Loire
fr:region:24@2015-01-18;24;2015-1-18 0:00:00;9999-12-31 23:59:59;Centre-Val de Loire;;fr:region:24@1970-01-09;2570546;39151;FR24;fr:commune:45234@1942-01-01;https://fr.wikipedia.org/wiki/Centre-Val_de_Loire

Link to INSEE page

communes rétablies qui n'ont pas le bon codegeo

Bonjour,

J'ai constaté un problème sur les Pays de la Loire. 5 communes qui ont en commun d'avoir été rattachées puis rétablies n'ont pas le bon codegeo 2017.

codegeo2017 | codegeohisto
53111 | 53003
53213 | 53181
53238 | 53181
85045 | 85002
85055 | 85003

J'espère poster au bon endroit, je ne suis pas très familière de github!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.