Description
geopy ===== .. image:: https://img.shields.io/pypi/v/geopy.svg?style=flat-square :target: https://pypi.python.org/pypi/geopy/ :alt: Latest Version .. image:: https://img.shields.io/github/actions/workflow/status/geopy/geopy/ci.yml?branch=master&style=flat-square :target: https://github.com/geopy/geopy/actions/workflows/ci.yml?query=branch%3Amaster :alt: Build Status .. image:: https://img.shields.io/github/license/geopy/geopy.svg?style=flat-square :target: https://pypi.python.org/pypi/geopy/ :alt: License geopy is a Python client for several popular geocoding web services. geopy makes it easy for Python developers to locate the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources. geopy includes geocoder classes for the `OpenStreetMap Nominatim`_, `Google Geocoding API (V3)`_, and many other geocoding services. The full list is available on the `Geocoders doc section`_. Geocoder classes are located in `geopy.geocoders`_. .. _OpenStreetMap Nominatim: https://nominatim.org .. _Google Geocoding API (V3): https://developers.google.com/maps/documentation/geocoding/ .. _Geocoders doc section: https://geopy.readthedocs.io/en/latest/#geocoders .. _geopy.geocoders: https://github.com/geopy/geopy/tree/master/geopy/geocoders geopy is tested against CPython (versions 3.7, 3.8, 3.9, 3.10, 3.11, 3.12) and PyPy3. geopy 1.x line also supported CPython 2.7, 3.4 and PyPy2. © geopy contributors 2006-2018 (see AUTHORS) under the `MIT License <https://github.com/geopy/geopy/blob/master/LICENSE>`__. Installation ------------ Install using `pip <http://www.pip-installer.org/en/latest/>`__ with: :: pip install geopy Or, `download a wheel or source archive from PyPI <https://pypi.python.org/pypi/geopy>`__. Geocoding --------- To geolocate a query to an address and coordinates: .. code:: pycon >>> from geopy.geocoders import Nominatim >>> geolocator = Nominatim(user_agent="specify_your_app_name_here") >>> location = geolocator.geocode("175 5th Avenue NYC") >>> print(location.address) Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ... >>> print((location.latitude, location.longitude)) (40.7410861, -73.9896297241625) >>> print(location.raw) {'place_id': '9167009604', 'type': 'attraction', ...} To find the address corresponding to a set of coordinates: .. code:: pycon >>> from geopy.geocoders import Nominatim >>> geolocator = Nominatim(user_agent="specify_your_app_name_here") >>> location = geolocator.reverse("52.509669, 13.376294") >>> print(location.address) Potsdamer Platz, Mitte, Berlin, 10117, Deutschland, European Union >>> print((location.latitude, location.longitude)) (52.5094982, 13.3765983) >>> print(location.raw) {'place_id': '654513', 'osm_type': 'node', ...} Measuring Distance ------------------ Geopy can calculate geodesic distance between two points using the `geodesic distance <https://en.wikipedia.org/wiki/Geodesics_on_an_ellipsoid>`_ or the `great-circle distance <https://en.wikipedia.org/wiki/Great-circle_distance>`_, with a default of the geodesic distance available as the function `geopy.distance.distance`. Here's an example usage of the geodesic distance, taking pair of :code:`(lat, lon)` tuples: .. code:: pycon >>> from geopy.distance import geodesic >>> newport_ri = (41.49008, -71.312796) >>> cleveland_oh = (41.499498, -81.695391) >>> print(geodesic(newport_ri, cleveland_oh).miles) 538.390445368 Using great-circle distance, also taking pair of :code:`(lat, lon)` tuples: .. code:: pycon >>> from geopy.distance import great_circle >>> newport_ri = (41.49008, -71.312796) >>> cleveland_oh = (41.499498, -81.695391) >>> print(great_circle(newport_ri, cleveland_oh).miles) 536.997990696 Documentation ------------- More documentation and examples can be found at `Read the Docs <http://geopy.readthedocs.io/en/latest/>`__.
Release History
| Version | Changes | Urgency | Date |
|---|---|---|---|
| 2.4.1 | Imported from PyPI (2.4.1) | Low | 4/21/2026 |
| 2.4.0 | ## New Features - New geocoder: `.Woosmap`. Contributed by galela. (#541) - New geocoder: `.Geokeo`. Contributed by Geokeo. (#490) ## Breaking Changes - Removed Algolia Places geocoder: the service is shut down. Contributed by mtmail. (#547) ## Packaging Changes - Add support for Python 3.12. (#559) - Update maintainer email. - GitHub releases are now signed with GPG. (#550) - tests: switch from httpbin.org to httpbingo.org. (#551) - tests: use tox `allowlist_externa | Low | 8/27/2023 |
| 2.3.0 | ## New Features - `.MapBox`: add `referer` param to allow restricted api_keys. Contributed by Dennis Stritzke. (#501) - `.MapBox`: add `language` param to `geocode`. Contributed by Dennis Stritzke. (#503) - `.Distance`: add floor division + right multiplication operators. (#485) - `.Distance`: make hashable. (#485) - `.Nominatim`: add `namedetails` param to `reverse`. (#525) - `.Pelias`: add `countries` param to `geocode`. (#504) - `.GoogleV3`: pass the original `error_message` | Low | 11/13/2022 |
| 2.2.0 | ## New Features - `.OpenCage`: added `annotations` param. Contributed by mtmail. (#464) - `.Photon`: added `bbox` param. Contributed by Holger Bruch. (#472) - New geocoder: `.Geocodio`. Contributed by Jon Duckworth. (#468) - New geocoder: `.HereV7`. Contributed by Pratheek Rebala. (#433) - New geocoder: `.What3WordsV3`. Contributed by Saïd Tezel. (#444) - New error class: `.exc.GeocoderRateLimited`. This error extends `.exc.GeocoderQuotaExceeded` and is now raised inste | Low | 7/11/2021 |
| 2.1.0 | ## New Features - Add support for leading plus sign in the `.Point` constructor. Contributed by Azimjon Pulatov. (#448) ## Breaking Changes - `.GoogleV3`: change missing `api_key` warning to an error. (#450) ## Bugfixes - Fixed an undocumented breaking change in geopy 2.0.0, where the `.Distance` class has become abstract, thus it could no longer be used for unit conversions. (#435) - `.Photon` incorrectly treated 0.0 coordinate as an empty response. Contributed by Ma | Low | 12/27/2020 |
| 2.0.0 | geopy 2.0 is a major release with lots of cleanup and inner refactorings. The public interface of the library is mostly the same, and the set of supported geocoders didn't change. If you have checked your code on the latest 1.x release with enabled warnings (i.e. with `-Wd` key of the `python` command) and fixed all of them, then it should be safe to upgrade. ## New Features - `geopy.adapters` module. Previously all geocoders used `urllib` for HTTP requests, which doesn't support | Low | 6/27/2020 |
| 1.23.0 | This is the last feature release for the 1.x series, as geopy 2.0 has been released. The 1.x series will not receive any new features or bugfixes unless explicitly asked on the issue tracker. * ADDED: `Units Conversion` docs section. * ADDED: Docs now explicitly clarify that geocoding services don't consider altitudes. (#165) * ADDED: `Point.format_unicode` method. It was always present as `__unicode__` magic for Python 2.7, and now it can be accessed as a public | Low | 6/27/2020 |
| 2.0.0rc1 | geopy 2.0 is a major release with lots of cleanup and inner refactorings. The public interface of the library is mostly the same, and the set of supported geocoders didn't change. If you have checked your code on the latest 1.x release with enabled warnings (i.e. with `-Wd` key of the `python` command) and fixed all of them, then it should be safe to upgrade. ## New features - `geopy.adapters` module. Previously all geocoders used `urllib` for HTTP requests, which doesn't support | Low | 6/21/2020 |
| 1.22.0 | * ADDED: `AlgoliaPlaces` geocoder. Contributed by Álvaro Mondéjar. (#405) * ADDED: `BaiduV3` geocoder. (#394) * ADDED: `MapQuest` geocoder. Contributed by Pratheek Rebala. (#399) * ADDED: `MapTiler` geocoder. Contributed by chilfing. (#397) * ADDED: `Nominatim`-based geocoders: `zoom` parameter has been added to the `reverse` method. Contributed by David Mueller. (#406) * ADDED: `GoogleV3` added support for lists in `components` param whic | Low | 5/11/2020 |
| 1.21.0 | * ADDED: `HERE` geocoder now supports the new API KEY authentication method. The old one is marked as deprecated and now issues a warning. Contributed by deeplook. (#388) * ADDED: `Nominatim`-based geocoders: `featuretype` parameter has been added to the `geocode` method. Contributed by Sergio Martín Morillas. (#365) * ADDED: `Nominatim`-based geocoders: `namedetails` parameter has been added to the `geocode` method. Contributed by enrique a. (#368) * | Low | 2/2/2020 |
| 1.20.0 | * FIXED: `MapBox`'s `geocode` method was ignoring the `exactly_one` parameter. Contributed by TheRealZeljko. (#358) * FIXED: The resulting `Location`'s `raw` attribute in `MapBox` erroneously contained a single string instead of a full service response. This might be considered a breaking change (although it's unlikely that the previous `raw` value was usable at all). Contributed by Sergey Lyapustin and TheRealZeljko. (#354) | Low | 2/2/2020 |
| 1.19.0 | * ADDED: `GoogleV3`: `place_id` arg has been added to the `geocode` method. Contributed by Mesut Öncel. (#348) * ADDED: `Geolake`, `GeoNames`, `MapBox`, `OpenCage`, `OpenMapQuest`, `Nominatim` and `PickPoint` geocoders now also accept Python lists of countries instead of just a single string. (#349) * CHANGED: `geocode`-specific args have been moved to `geocode` methods from `__init__`, and the corresponding `__init__` args has been deprecated. The affected g | Low | 3/26/2019 |
| 1.18.1 | * FIXED: `GeoNames.reverse_timezone` didn't process errors returned by API and instead was always raising obscure `KeyError` exceptions. * FIXED: `GeoNames.reverse_timezone` raised `KeyError` for points which don't have an assigned Olson timezone ID (e.g. Antarctica). Now a valid `geopy.Timezone` is returned for such, where pytz timezone is created as `pytz.FixedOffset`. * FIXED: `GoogleV3.reverse_timezone` raised `KeyError` for points which don't have an ass | Low | 12/16/2018 |
| 1.18.0 | The work on geopy 2.0 has started, see the new `geopy 2.0` doc section for more info. geopy 2.0 will drop support for Python 2.7 and 3.4. To ensure a smoother transition from 1.x to 2.0, make sure to check your code with warnings enabled (i.e. run python with the ``-Wd`` switch). * ADDED: Geolake geocoder. Contributed by Yorick Holkamp. (#329) * ADDED: BANFrance (Base Adresse Nationale) geocoder. Contributed by Sébastien Barré. (#336) * ADDED: TomTom and AzureMaps: `langu | Low | 12/2/2018 |
| 1.17.0 | * ADDED: OpenMapQuest how inherits from Nominatim. This adds support for all parameters and queries implemented in Nominatim (such as reverse geocoding). (#319) * ADDED: Nominatim-based geocoders now support an `extratags` option. Contributed by Oleg. (#320) * ADDED: Mapbox geocoder. Contributed by William Hammond. (#323) * ADDED: ArcGIS now supports custom `domain` and `auth_domain` values. Contributed by Albina. (#325) * ADDED: Bodies of unsuccessful H | Low | 9/13/2018 |
| 1.16.0 | * ADDED: `geopy.extra.rate_limiter.RateLimiter` class, useful for bulk-geocoding a pandas DataFrame. See also the new `Usage with Pandas` doc section. (#317) * CHANGED: Nominatim now issues a warning when the default user_agent is used against `nominatim.openstreetmap.org`. Please always specify a custom user-agent when using Nominatim. (#316) | Low | 7/28/2018 |
| 1.15.0 | * ADDED: GeocodeEarth geocoder based on Pelias (ex-Mapzen). (#309) * ADDED: TomTom and AzureMaps (based on TomTom) geocoders. (#312) * ADDED: HERE geocoder. Contributed by deeplook. (#304) * ADDED: Baidu now supports authentication using SK via a new `security_key` option. Contributed by tony. (#298) * ADDED: Nominatim's and Pickpoint's `view_box` option now accepts a list of Points or numbers instead of just stringified coordinates. Contributed by svale | Low | 7/15/2018 |
| 1.14.0 | This release contains a lot of public API cleanup. Also make sure to check out the updated docs! A new `Semver` doc section has been added, explaining the geopy's policy on breaking changes. * ADDED: Nominatim geocoder now supports an `addressdetails` option in the `reverse` method. Contributed by Serphentas. (#285) * ADDED: ArcGIS geocoder now supports an `out_fields` option in the `geocode` method. Contributed by Jonathan Batchelor. (#227) * ADDED: Yandex g | Low | 5/13/2018 |
| 1.13.0 | * ADDED: Pickpoint geocoder. Contributed by Vladimir Kalinkin. (#246) * ADDED: Bing geocoder: additional parameters for geocoding (`culture` and `include_country_code`). Contributed by Bernd Schlapsi. (#166) * ADDED: `Point` and `Location` instances are now picklable. * ADDED: More accurate algorithm for distance computation `geopy.distance.geodesic`, which is now a default `geopy.distance.distance`. Vincenty usage is now discouraged in favor of the geodesic. | Low | 4/12/2018 |
| 1.12.0 | * ADDED: Mapzen geocoder. Contributed by migurski. (#183) * ADDED: GoogleV3 geocoder now supports a `channel` option. Contributed by gotche. (#206) * ADDED: Photon geocoder now accepts a new `limit` option. Contributed by Mariana Georgieva. * CHANGED: Use the IUGG mean earth radius for EARTH_RADIUS. Contributed by cffk. (#151) * CHANGED: Use the exact conversion factor from kilometers to miles. Contributed by cffk. (#150) * CHANGED: OpenMapQuest geo | Low | 3/13/2018 |
| 1.11.0 | * ADDED: Photon geocoder. Contributed by mthh. * ADDED: Bing supports structured query parameters. Contributed by SemiNormal. * CHANGED: Geocoders send a `User-Agent` header, which by default is `geopy/1.11.0`. Configure it during geocoder initialization. Contributed by sebastianneubauer. * FIXED: Index out of range error with no results using Yandex. Contributed by facciocose. * FIXED: Nominatim was incorrectly sending `view_box` when not requested, and form | Low | 3/13/2018 |
| 1.10.0 | - CHANGED: GeocodeFarm now uses version 3 of the service's API, which allows use by unauthenticated users, multiple results, and SSL/TLS. You may need to obtain a new API key from GeocodeFarm, or use `None` for their free tier. Contributed by Eric Palakovich Carr. - ADDED: DataBC geocoder for use with the British Columbia government's DataBC service. Contributed by Benjamin Trigona-Harany. - ADDED: Placefinder's geocode method now requests a timezone if the `with_timezone` parameter is | Low | 4/5/2015 |
| 1.9.1 | - FIXED: Fix support for GoogleV3 bounds parameter. Contributed by Benjamin Trigona-Harany. | Low | 2/17/2015 |
| 1.9.0 | - CHANGED: MapQuest geocoder removed as the API it uses is now only available to enterprise accounts. OpenMapQuest is a replacement for Nominatim-sourced data. - CHANGED: Nominatim now uses HTTPS by default and accepts a `scheme` argument. Contributed by srounet. - ADDED: Nominatim now accepts a `domain` argument, which allows using a different server than `nominatim.openstreetmap.org`. Contributed by srounet. - FIXED: Bing was not accessible from `get_geocoder_for_service`. Contribute | Low | 2/12/2015 |
| 1.8.1 | - FIXED: GoogleV3 geocoder did not send API keys for reverse and timezone methods. | Low | 1/28/2015 |
| 1.8.0 | - ADDED: NaviData geocoder added. Contributed by NaviData. - CHANGED: LiveAddress now requires HTTPS connections. If you set `scheme` to be `http`, rather than the default `https`, you will now receive a `ConfigurationError`. | Low | 1/22/2015 |
| 1.7.1 | - FIXED: IGN France geocoder's address formatting better handles results that do not have a building number. Contributed by Thomas Gratier. | Low | 1/6/2015 |
| 1.7.0 | - ADDED: IGNFrance geocoder. Contributed by Thomas Gratier. - FIXED: Bing checks the response body for error codes. | Low | 12/30/2014 |
| 1.6.1 | - FIXED: What3Words validation loosened. Contributed by spatialbitz. - FIXED: Point.format() includes altitude. | Low | 12/12/2014 |
| 1.6.0 | - ADDED: Python 3.2 and PyPy3 compatibility. Contributed by Mike Toews. | Low | 12/9/2014 |
| 1.5.0 | - ADDED: Yandex geocoder added. Contributed by htch. - ADDED: What3Words geocoder added. Contributed by spatialbitz. - FIXED: LiveAddress geocoder made compatible with a change in the service's authentication. An `auth_id` parameter was added to the geocoder's initialization. Contributed by Arsen Mamikonyan. | Low | 12/7/2014 |
| 1.4.0 | - ADDED: Mapquest.reverse() method added. Contributed by Dody Suria Wijaya. - ADDED: Bing's geocoder now accepts the optional arguments "culture", "includeNeighborhood", and "include". Contributed by oskholl. | Low | 11/8/2014 |
| 1.1.3 | - FIXED: Fix OpenCage AttributeError on empty result. Contributed by IsaacHaze. | Low | 9/23/2014 |
| 1.1.4 | - FIXED: Point.format() seconds precision in Python 3. | Low | 9/23/2014 |
| 1.1.5 | - FIXED: YahooPlaceFinder is now compatible with the older requests_oauthlib version 0.4.0. | Low | 9/23/2014 |
| 1.2.0 | - ADDED: GeoNames.reverse() added. Contributed by Emile Aben. - ADDED: GoogleV3.timezone() added. This returns a pytz object giving the timezone in effect for a given location at a time (defaulting to now). | Low | 9/23/2014 |
| 1.3.0 | - ADDED: Nominatim.geocode() accepts a `geometry` argument for retrieving `wkt`, `svg`, `kml`, or `geojson` formatted geometries in results. Contributed by spatialbitz. | Low | 9/23/2014 |
