mongiris package
This package is an interface for querying French administrative areas (IRIS, similar to neighborhoods) stored as documents in MongoDB.
Each IRIS includes indicators (e.g., average income, types of housings, number of bakeries or schools) that are useful for social sciences studies, for house/neighborhood recommendation, etc.
In this package, the ~50,000 IRIS and their 350-650 indicators have been integrated and stored in the GeoJSON format, and an API enables the manipulation of these data.
Pré-requis
- Python, version >=3
- MongoDB, version >=4, in which it is necessary to import the IRIS database (see Installation).
Installation
To install mongiris:
python3 -m pip install git+https://fduchate@gitlab.liris.cnrs.fr/fduchate/mongiris.git#egg=mongiris
Next, you need to load the IRIS data into MongoDB (using the mongorestore
tool):
mongorestore --archive=/path/to/dump-dbinsee.bin
where /path/to/
indicates the path to the dump database (provided with the source package mongiris in mongiris/data/dump/dump-dbinsee.bin
). This restoration may take a few minutes as the geospatial indexes are rebuilt.
In MongoDB, the database is named dbinsee
. It contains three collections:
-
collsources
stores information about original data sources (title, release date, geographical information) -
collindic
stores information about indicators (short label, full label, data sources in which it appears). -
colliris
is the main collection, which stores each IRIS with its indicators (according to the GeoJSON format)
Usage
To manipulate the database, simply connect to MongoDB by creating an object of the Mongiris
class.
Using this object, twenty methods are available for querying the data.
Below is a minimal example of connection and queries:
from mongiris.main import Mongiris
db = Mongiris()
# return the number of documents in a collection
counts = db.count_documents(db.collection_indic, {})
# get complete information about iris identified with code 593500203
iris = db.find_one_document(db.collection_iris, {"properties.CODE_IRIS": "593500203"})
# get iris which contains coordinates 3.685111, 46.514643
doc = db.point_in_which_iris([3.685111, 46.514643])
More examples, including testing geospatial queries, are available in the tests/mongiris_test.py
file.
Contributors
-
Fabien Duchateau, Franck Favetta (laboratory LIRIS, Université Lyon 1)
-
Loïc Bonneval (laboratory CMW, Université Lyon 2)
Acknowledgments
Data source provider :
Financial support :