All Projects → OpenCageData → python-opencage-geocoder

OpenCageData / python-opencage-geocoder

Licence: other
Python module to access the OpenCage geocoding API

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to python-opencage-geocoder

php-opencage-geocode
PHP library to access the OpenCage geocoding API
Stars: ✭ 26 (-51.85%)
Mutual labels:  geocoding, opencage, opencage-geocoder
leaflet-opencage-search
A Leaflet geocoding control that uses the OpenCage geocoding API
Stars: ✭ 18 (-66.67%)
Mutual labels:  geocoding, opencage
opencage
🌐 R package for the OpenCage API -- both forward and reverse geocoding 🌐
Stars: ✭ 82 (+51.85%)
Mutual labels:  opencage, opencage-geocoder
h3-r
R bindings for H3, a hierarchical hexagonal geospatial indexing system
Stars: ✭ 57 (+5.56%)
Mutual labels:  geocoding
django-mapbox-location-field
Simple in use location model and form field with MapInput widget for picking some location. Uses mapbox gl js, flexible map provider API. Fully compatible with bootstrap framework. Can be used with spatial or plain databases.
Stars: ✭ 60 (+11.11%)
Mutual labels:  geocoding
Atlas
🌎 Atlas is a set of APIs for looking up information about locations
Stars: ✭ 21 (-61.11%)
Mutual labels:  geocoding
geocoding
地理编码技术,提供地址标准化和相似度计算。
Stars: ✭ 148 (+174.07%)
Mutual labels:  geocoding
cordova-plugin-radar
Cordova plugin for Radar, the leading geofencing and location tracking platform
Stars: ✭ 14 (-74.07%)
Mutual labels:  geocoding
Osmunda
An offline geocode library for android, powered by SQLite, using osm data. 离线地理编码Android库,基于SQLite,使用开放街道地图数据。
Stars: ✭ 37 (-31.48%)
Mutual labels:  geocoding
geocoder
Web app interface for geocoding addresses in CSV files.
Stars: ✭ 17 (-68.52%)
Mutual labels:  geocoding
Geocoding-with-Map-Vector
Resources for the ACL 2018 publication "Which Melbourne? Augmenting Geocoding with Maps", published in July 2018.
Stars: ✭ 24 (-55.56%)
Mutual labels:  geocoding
open route service
An encapsulation made around openrouteservice API for Dart and Flutter projects. Made for easy generation of Routes and Directions on Maps, Isochrones, Time-Distance Matrix, Pelias Geocoding, POIs, Elevation and routing Optimizations using their amazing API.
Stars: ✭ 20 (-62.96%)
Mutual labels:  geocoding
python-omgeo
OMGeocoder - A python geocoding abstraction layer
Stars: ✭ 34 (-37.04%)
Mutual labels:  geocoding
python-censusbatchgeocoder
A simple Python wrapper for U.S. Census Geocoding Services API batch service
Stars: ✭ 40 (-25.93%)
Mutual labels:  geocoding
geocoder
Geocoder is a Typescript library which helps you build geo-aware applications by providing a powerful abstraction layer for geocoding manipulations
Stars: ✭ 28 (-48.15%)
Mutual labels:  geocoding
ais
Address Information System
Stars: ✭ 18 (-66.67%)
Mutual labels:  geocoding
google maps
🗺 An unofficial Google Maps Platform client library for the Rust programming language.
Stars: ✭ 40 (-25.93%)
Mutual labels:  geocoding
addressr
Free Australian Address Validation, Search and Autocomplete
Stars: ✭ 46 (-14.81%)
Mutual labels:  geocoding
rrgeo
A fast, offline, reverse geocoder
Stars: ✭ 76 (+40.74%)
Mutual labels:  geocoding
OpenNameSearch
Script for Building a Basic Nominatim Server
Stars: ✭ 14 (-74.07%)
Mutual labels:  geocoding

OpenCage Geocoding Module for Python

A Python module to access the OpenCage Geocoding API.

Build Status / Code Quality / etc

PyPI version Downloads Versions GitHub contributors Build Status Twitter Follow

Usage

Supports Python 3.6 or newer. Use the older opencage 1.x releases if you need Python 2.7 support.

Install the module:

pip install opencage

Load the module:

from opencage.geocoder import OpenCageGeocode

Create an instance of the geocoder module, passing a valid OpenCage Data Geocoder API key as a parameter to the geocoder modules's constructor:

key = 'your-api-key-here'
geocoder = OpenCageGeocode(key)

Pass a string containing the query or address to be geocoded to the modules's geocode method:

query = "82 Clerkenwell Road, London"
result = geocoder.geocode(query)

You can add additional parameters:

result = geocoder.geocode('London', no_annotations=1, language='es')

You can use the proximity parameter to provide the geocoder with a hint:

result = geocoder.geocode('London', proximity='42.828576, -81.406643')
print(result[0]['formatted'])
# u'London, ON N6A 3M8, Canada'

Reverse geocoding

Turn a lat/long into an address with the reverse_geocode method:

results = geocoder.reverse_geocode(51.51024, -0.10303)

Sessions

You can reuse your HTTP connection for multiple requests by using a with block. This can help performance when making a lot of requests:

queries = ['82 Clerkenwell Road, London', ...]
with OpenCageGeocode(key) as geocoder:
    # Queries reuse the same HTTP connection
    results = [geocoder.geocode(query) for query in queries]

Asycronous requests

You can run requests in parallel with the geocode_async and reverse_geocode_async method which have the same parameters and response as their synronous counterparts. You will need at least Python 3.7 and the asyncio and aiohttp packages installed.

async with OpenCageGeocode(key) as geocoder:
    results = await geocoder.geocode_async(address)

For a more complete example and links to futher tutorials on asycronous IO see batch.py in the examples directory.

Exceptions

If anything goes wrong, then an exception will be raised:

  • InvalidInputError for non-unicode query strings
  • UnknownError if there's some problem with the API (bad results, 500 status code, etc)
  • RateLimitExceededError if you go past your rate limit

Copyright & License

This software is copyright OpenCage GmbH. Please see LICENSE.txt

Who is OpenCage GmbH?

We run a worldwide geocoding API and geosearch service based on open data. Learn more about us.

We also run Geomob, a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy the Geomob podcast.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].