Geocoding
Geocoding is an address search engine for France. Unlike other APIs, it uses a database provided by the french government (Base Adresse Nationale - BAN) as the main source of information and does not impose any limit to the number of queries. The purpose of the project is to supply the needs of french data scientists that rely on geocoded data.
Getting Started
Prerequisites
Python version 3 installed locally
Pip installed locally
For using purposes
The package can easily be installed via pip:
pip install geocoding
Before the first use, you need to download the BAN database and process its files to unlock the functionalities of the package. All of this can be done with the following command (the whole process should take 30 minutes):
geocoding update
Alternatively, you can do it step by step with the following commands:
geocoding download geocoding decompress geocoding index
To unlock the reverse search, execute the following command:
geocoding reverse
Usage
The search engine
import geocoding
# -*- Complete search -*-
output = geocoding.find('91120', 'Palaiseau', '12, Bd des Maréchaux')
print(output['longitude'], output['latitude']) # 2.2099342 48.7099138
# -*- Incomplete search -*-
output = geocoding.find('91120', None, '12, Bd des Maréchaux')
print(output['quality']) # 1 -> It means that the search was successful
output = geocoding.find('91120', None, 'Bd des Maréchaux')
print(output['quality']) # 3 -> It means that the number was not found
output = geocoding.find('91120', 'Palaiseau', None)
print(output['quality']) # 4 -> It means that the street was not found
output = geocoding.find(None, 'Palaiseau', '12, Bd des Maréchaux')
print(output['quality']) # 1
output = geocoding.find(None, None, '12, Bd des Maréchaux')
print(output['postal']['code']) # 35800
print(output['commune']['nom']) # DINARD
print(output['voie']['nom']) # BOULEVARD DES MARECHAUX
# -*- Search with typos -*-
geocoding.find('91120', 'Palaiseau', '12, Bd des Maréchx')['quality'] # 1
geocoding.find('91120', 'Palaiau', '12, Bd des Maréchx')['quality'] # 1
geocoding.find('91189', 'Palaiseau', '12, Bd des Maréchx')['quality'] # 1
geocoding.find('91189', None, '12, Bd des Maréchx')['quality'] # 1
# -*- Flexible syntax -*-
geocoding.find('91120', 'Palaiseau')['quality'] # 4
geocoding.find(commune='Palaiseau')['quality'] # 4
geocoding.find('91120')['quality'] # 5
args = {
'code_postal': '91120',
'commune': 'Palaiseau',
'adresse': '12, Bd Marechaux'
}
geocoding.find(**args)
The reverse functionality
import geocoding
# longitude and latitude
query = (2.2099, 48.7099)
output = geocoding.near(query)
output['commune']['nom'] # PALAISEAU
output['voie']['nom'] # BOULEVARD DES MARECHAUX
Benchmarks
import geocoding
begin = time.time()
for _ in range(2000):
geocoding.find('91130', 'PALISEAU', '12 BD DES MARECHUX')
print(time.time() - begin, 'seconds') # 1.063 seconds
begin = time.time()
for _ in range(10000):
geocoding.find('91120', 'PALAISEAU', '12 BD DES MARECHAUX')
print(time.time() - begin, 'seconds') # 1.407 seconds
begin = time.time()
for _ in range(10000):
geocoding.find('75015', 'PARIS', '1 RUE SAINT CHARLES')
print(time.time() - begin, 'seconds') # 1.525 seconds
begin = time.time()
for _ in range(1000):
geocoding.near((2, 48))
print(time.time() - begin, 'seconds') # 0.922 seconds
Metadata
Release files for Geocoding 1.4.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Geocoding-1.4.3.tar.gz | 17.5 kB | Without provenance | Details for Geocoding-1.4.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Geocoding-1.4.3-py3-none-any.whl | Python 3 | none | any | Details for Geocoding-1.4.3-py3-none-any.whl |
Total release size: 43.5 kB
Release files / Geocoding-1.4.3.tar.gz
| Download URL | Geocoding-1.4.3.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77dc7072142eccb1a4645474c3788d77fa5d14baac914fdffe2c64f772197bf4
|
|
BLAKE2b-256 checksum How to use checksums |
e857274425940ae651408108b206a6b915d0f6301fdba80720d096e00c1e7ccb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.7
|
Release files / Geocoding-1.4.3-py3-none-any.whl
| Download URL | Geocoding-1.4.3-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f73b23fe772af98903c86fa85695d978cd4e57aa49b53d94b215c2fc5b0e0617
|
|
BLAKE2b-256 checksum How to use checksums |
5d4ca69bb9f9cf710535dcb4cedc0286fa54ed090d3f3eefaff21db2c515daee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.7
|
Security for Geocoding 1.4.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.