Geolocate
Georeferencing large amounts of data for free.
Special thanks to @brunodepauloalmeida and the whole team for the contributions.
How?
It's using the very same API that Waze uses to georeference addresses before it finds the best route to that destination. It requires no API keys, works really well and has fairly high throughput.
In order to make this package extensible, there's an abstract class
GeolocateEngine that defines the interface for the engines. This allows
for the addition of new engines without having to modify the code.
How do I use it?
First you have to install the geolocate package for Python 3.7+:
pip3 install geolocate
Then, for a single address:
>>> from geolocate import geolocate
>>> geolocate("1 Infinite Loop, Cupertino, CA 95014")
{'latitude': 37.3311841, 'longitude': -122.0287127}
Or, if you want to run things in parallel:
>>> from geolocate import geolocate_batch
>>> geolocate_batch(["1 Infinite Loop, Cupertino, CA 95014", "Eiffel Tower"])
100%|███████| 2/2 [00:01<00:00, 1.66it/s]
[{'latitude': 37.3311841, 'longitude': -122.0287127}, {'latitude': 48.8560934, 'longitude': 2.2930458}]
Advanced usage
Both geolocate and geolocate_batch accept the following keyword arguments:
- engine (
geolocate.engines.GeolocateEngine): Engine to use for geolocating the address. Defaults togeolocate.engines.WazeEngine - timeout (int): The timeout in seconds.
- tries (int): The number of attempts to geolocate the address.
- backoff_factor (float): The backoff factor. Delay will grow by
{backoff factor} * (2 ** ({number of total retries} - 1)). - on_not_found (str or callable): A callback function for when the
address is not found. The signature of the callback function
should be:
def callback(address: str): ...
whereaddressis the address that was not found. The return value of the callback function is returned by the geolocate function. - on_error (str or callable): A callback function for when an error
occurs. The signature of the callback function should be:
def callback(address: str, error: Exception): ...
whereaddressis the address that caused the error anderroris the exception that occurred. The return value of the callback function is returned by the geolocate function.
In addition, the geolocate_batch function accepts the following
keyword arguments:
- num_cpus (int): The number of CPUs to use. If None, the number of CPUs will be determined automatically.
Metadata
Release files for geolocate 0.1.2
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 | |
|---|---|---|---|---|
| geolocate-0.1.2.tar.gz | 17.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| geolocate-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.7 kB
Release files / geolocate-0.1.2.tar.gz
| Download URL | geolocate-0.1.2.tar.gz |
|---|---|
| Size | 17.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fab141353380ede2e4b7ab87eb85f54c34ef8854e9360caada7deb9d1bfa187
|
|
BLAKE2b-256 checksum How to use checksums |
ef37a9cf8dafea951dba7261558644b4b7a6c6d071b920fa25ed01ccf774efe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.2 Linux/5.15.0-1024-azure
|
Release files / geolocate-0.1.2-py3-none-any.whl
| Download URL | geolocate-0.1.2-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d3417a3711c3aea362d7fb08476ac82e4b8dd2f94e9bc7a0ae246cea0b993b1
|
|
BLAKE2b-256 checksum How to use checksums |
1eb9d8050cd33aec221fdc993b2db4897e33778eba5b59c33a4a26bbf40ed07a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.2 CPython/3.10.2 Linux/5.15.0-1024-azure
|
Security for geolocate 0.1.2
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.