Carte is a flexible, extensible reverse-geocode library.
Carte is a flexible, extensible reverse-geocode library implemented in Python.
From PyPI via
pip install carte
From source using
Note: It is recommended to build
carte in a virtual environment due to dependency version requirements.
From the root of the repository, install the necessary dependencies via
Then, build the wheel:
Finally, outside of your virtual environment, install the wheel using
pip install dist/carte-<version>-py3-none-any.whl
Carte is built using resources which inherit from the
Resource class. A
Carte instance is instantiated with a list of the
Resource types it will query:
import carte carte_instance = carte.Carte([my_resource_type]) results = carte_instance.query(List of coordinates as tuples...)
Carte instances may be created, and resources will be shared between them by a backing
The flexibility of Carte lies in the
Resource class, which queries are passed to sequentially via the
query method. The results of each resource query are aggregated and passed to the next, allowing the creation of resources that mutate previous resources' results, such as translating a country's ISO 3166-1 identifier code into a full name.
For examples of
Resource classes, see the
Defining your own
Resource is as simple as inheriting from the
Resource superclass, and implementing the
from carte.resources import resource class MyCustomResource(resource.Resource): def load(self): # do stuff... def query(self, coordinates, results) -> dict: # do other stuff... return results
To run tests, execute the following from the root of the project:
poetry run pytest tests/
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.