send_the_raven.geoaddress.Geocoder#
- class send_the_raven.geoaddress.Geocoder[source]#
Bases:
Addresses
Geocoder for Geoaddresses. When the instance is called, it will start geocoding addresses with geopy_geocoder of your choice.
Example
>>> addresses = [GeoAddress(...), ...] >>> geocoder = Geocoder(addresses) >>> geocoder("nominatim", {"user_agent": "my_app"}) >>> for address in geocoder.addresses: >>> print(address.latitude, address.longitude)
- __init__(addresses, field_mapping={'address_line_2': 'address_line_2', 'city': 'city', 'full_address': 'full_address', 'id': 'id', 'latitude': 'latitude', 'longitude': 'longitude', 'state': 'state', 'street': 'street', 'zip_code': 'zip_code'})[source]#
- __call__(geocoder_name, args)[source]#
Start Geocode the addresses. This function will return adter all addresses are geocoded.
Methods
__eq__
(value, /)Return self==value.
__getitem__
(index)__init__
(addresses[, field_mapping])__iter__
()__len__
()geocode
(address, geocoder)Geocode address with geopy_geocoder.
normalize_parallel
([number_of_proccesses])Normalize all addresses in parallel.
start_geocode
(geocoder_name, args)Start geocoding process asyncronously.
- __init__(addresses, field_mapping={'address_line_2': 'address_line_2', 'city': 'city', 'full_address': 'full_address', 'id': 'id', 'latitude': 'latitude', 'longitude': 'longitude', 'state': 'state', 'street': 'street', 'zip_code': 'zip_code'})[source]#
- async geocode(address, geocoder)[source]#
Geocode address with geopy_geocoder. If geocoding fails, the address is added to the errors list. When you are bringing your own async runner, limiter, geocoder, feel free to use this function by providing it the geocoder.
- Parameters:
address (GeoAddress) – Address to geocode.
geocoder (geopy.extra.rate_limiter.AsyncRateLimiter) – Geocoder
RateLimiter. (instance wraped with) –
- normalize_parallel(number_of_proccesses=None)#
Normalize all addresses in parallel. Uses
multiprocessing.Pool.map()
.- Parameters:
number_of_proccesses (int) – number of process
- async start_geocode(geocoder_name, args)[source]#
Start geocoding process asyncronously. If you want to use a less stricting
AsyncRateLimiter
, feel free to use your own. If you have your own async runner, feel free to run this function on your own.- Parameters:
geocoder_name (str) – Geocoder to use.
*args – Arguments to pass to
geopy.geocoders.get_geocoder_for_service()
.