kblais/france-cities-seeds

Extract the tree structure of French metropolitan regions, departments and cities from www.data.gouv.fr CSV

1.0.0 2016-08-24 09:47 UTC

This package is auto-updated.

Last update: 2021-10-11 21:24:08 UTC


README

This package extracts the tree structure of French metropolitan regions, departments and cities from the CSV file provided by www.data.gouv.fr.

Usage

Place the extracted CSV file (available at this address : www.data.gouv.fr/fr/datasets/decoupage-administratif-communal-francais-issu-d-openstreetmap/) in the folder you need, and use the extractFromFile($filepath) function to extract data :

$regions = Kblais\FranceCitiesSeeds\extractFromFile('/path/to/csv/file.csv');

Output extract

[
    11 => [
        "name" => "ILE-DE-FRANCE",
        "code" => "11",
        "departments" => [
            78 => [
                "name" => "YVELINES",
                "code" => "78",
                "cities" => [
                    78165 => [
                        "insee_code" => "78165",
                        "name" => "Les Clayes-sous-Bois",
                        "surface" => "6111331.000000000000000",
                        "lat" => "1.983682382432120",
                        "lon" => "48.818793614296297",
                        "status" => "Commune simple",
                        "population" => "17.5",
                        "canton_code" => "38",
                        "district_code" => "4",
                    ],
                    78674 => [
                        "insee_code" => "78674",
                        "name" => "Villepreux",
                        "surface" => "10446819.000000000000000",
                        "lat" => "2.012416565085020",
                        "lon" => "48.831123160333597",
                        "status" => "Commune simple",
                        "population" => "9.9",
                        "canton_code" => "22",
                        "district_code" => "3",
                    ],
                    ...
                ],
            ],
            ...
        ],
    ],
    ...
]