reverse_geocoder

A fast, offline reverse geocoder in Python

https://github.com/thampiman/reverse-geocoder

Science Score: 10.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    2 of 7 committers (28.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.2%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

A fast, offline reverse geocoder in Python

Basic Info
  • Host: GitHub
  • Owner: thampiman
  • License: lgpl-2.1
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 24.8 MB
Statistics
  • Stars: 1,893
  • Watchers: 35
  • Forks: 159
  • Open Issues: 44
  • Releases: 2
Created over 11 years ago · Last pushed over 3 years ago
Metadata Files
Readme License

README.md

Reverse Geocoder

A Python library for offline reverse geocoding. It improves on an existing library called reverse_geocode developed by Richard Penman.

UPDATE (15-Sep-16): v1.5.1 released! See release notes below.

About

Ajay Thampi | @thampiman | opensignal.com | ajaythampi.com

Features

  1. Besides city/town and country code, this library also returns the nearest latitude and longitude and also administrative regions 1 and 2.
  2. This library also uses a parallelised implementation of K-D trees which promises an improved performance especially for large inputs.

By default, the K-D tree is populated with cities that have a population > 1000. The source of the data is GeoNames. You can also load a custom data source so long as it is a comma-separated file with header (like rg_cities1000.csv), containing the following columns:

  • lat: Latitude
  • lon: Longitude
  • name: Name of place
  • admin1: Admin 1 region
  • admin2: Admin 2 region
  • cc: ISO 3166-1 alpha-2 country code

For usage instructions, see below.

Installation

For first time installation, $ pip install reverse_geocoder

Or upgrade an existing installation using, $ pip install --upgrade reverse_geocoder

Package can be found on PyPI.

Dependencies

  1. scipy
  2. numpy

Release Notes

  1. v1.0 (27-Mar-15) - First version with support for only Python2
  2. v1.1 (28-Mar-15) - Fix for issue #1 by Brandon
  3. v1.2 (30-Mar-15) - Support for Python 3, conversion of Geodetic coordinates to ECEF for use in K-D trees to find nearest neighbour using the Euclidean distance function. This release fixes issues #2 and #8. Special thanks to David for his help in partly fixing #2.
  4. v1.3 (11-Apr-15) - This release fixes issues #9, #10, #11 and #12. License has been changed from MIT to LGPL (see #12).
  5. v1.4 (08-Jul-16) - Included numpy and scipy as dependencies in setup.
  6. v1.5 (15-Sep-16) - Support for custom data source and fixes for issues #16 and #24. Hat tip to Jason and Gregoire.
  7. v1.5.1 (15-Sep-16) - Fix for #26.

Usage

The library supports two modes:

  1. Mode 1: Single-threaded K-D Tree (similar to reverse_geocode)
  2. Mode 2: Multi-threaded K-D Tree (default)

```python import reverse_geocoder as rg

coordinates = (51.5214588,-0.1729636),(9.936033, 76.259952),(37.38605,-122.08385)

results = rg.search(coordinates) # default mode = 2

print results ```

The above code will output the following: [{'name': 'Bayswater', 'cc': 'GB', 'lat': '51.51116', 'lon': '-0.18426', 'admin1': 'England', 'admin2': 'Greater London'}, {'name': 'Cochin', 'cc': 'IN', 'lat': '9.93988', 'lon': '76.26022', 'admin1': 'Kerala', 'admin2': 'Ernakulam'}, {'name': 'Mountain View', 'cc': 'US', 'lat': '37.38605', 'lon': '-122.08385', 'admin1': 'California', 'admin2': 'Santa Clara County'}]

If you'd like to use the single-threaded K-D tree, set mode = 1 as follows: python results = rg.search(coordinates,mode=1)

To use a custom data source for geocoding, you can load the file in-memory and pass it to the library as follows: ```python import io import reverse_geocoder as rg

geo = rg.RGeocoder(mode=2, verbose=True, stream=io.StringIO(open('custom_source.csv', encoding='utf-8').read())) coordinates = (51.5214588,-0.1729636),(9.936033, 76.259952),(37.38605,-122.08385) results = geo.query(coordinates) ```

As mentioned above, the custom data source must be comma-separated with a header as rg_cities1000.csv.

Performance

The performance of modes 1 and 2 are plotted below for various input sizes.

Performance Comparison

Mode 2 runs ~2x faster for very large inputs (10M coordinates).

Acknowledgements

  1. Major inspiration is from Richard Penman's reverse_geocode library
  2. Parallelised implementation of K-D Trees is extended from this article by Sturla Molden
  3. Geocoded data is from GeoNames

License

Copyright (c) 2015 Ajay Thampi and contributors. This code is licensed under the LGPL License.

Owner

  • Name: Ajay Thampi
  • Login: thampiman
  • Kind: user
  • Location: London
  • Company: @facebook

Machine Learning Engineer at Facebook | PhD in Signal Processing & Wireless Communications

GitHub Events

Total
  • Issues event: 2
  • Watch event: 24
  • Fork event: 2
Last Year
  • Issues event: 2
  • Watch event: 24
  • Fork event: 2

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 57
  • Total Committers: 7
  • Avg Commits per committer: 8.143
  • Development Distribution Score (DDS): 0.123
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Ajay Thampi a****i@g****m 50
Alex Thompson g****r@a****u 2
Mehdi m****s@f****m 1
Geoffrey Fairchild g****d@l****v 1
David J. Felix f****j@g****m 1
Brandon Liu b****n@b****g 1
Jason Swails j****s@l****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 50
  • Total pull requests: 25
  • Average time to close issues: 19 days
  • Average time to close pull requests: about 2 months
  • Total issue authors: 48
  • Total pull request authors: 21
  • Average comments per issue: 1.28
  • Average comments per pull request: 0.52
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: 11 days
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 0.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • thampiman (2)
  • rchrd2 (2)
  • apiszcz (1)
  • ChristelleV (1)
  • kalefranz (1)
  • Ayano-Keiko (1)
  • jsdunn50 (1)
  • aliva (1)
  • pyrossh (1)
  • dacoex (1)
  • thewchan (1)
  • gfairchild (1)
  • WillAyd (1)
  • jerblack (1)
  • ShirleiAlexandrino (1)
Pull Request Authors
  • thampiman (3)
  • DavidJFelix (2)
  • TalAmuyal (2)
  • mazieres (1)
  • sefitz (1)
  • allenlawrence94 (1)
  • dylanlittler (1)
  • bdon (1)
  • GiorgioBalestrieri (1)
  • serhii73 (1)
  • swails (1)
  • godfoder (1)
  • mehdilauters (1)
  • gfairchild (1)
  • rhodes73 (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 251,323 last-month
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 97
    (may contain duplicates)
  • Total versions: 10
  • Total maintainers: 1
pypi.org: reverse_geocoder

Fast, offline reverse geocoder

  • Versions: 9
  • Dependent Packages: 1
  • Dependent Repositories: 96
  • Downloads: 251,323 Last month
Rankings
Downloads: 0.7%
Dependent repos count: 1.5%
Stargazers count: 1.6%
Average: 2.5%
Forks count: 3.9%
Dependent packages count: 4.7%
Maintainers (1)
Last synced: 11 months ago
conda-forge.org: reverse_geocoder

A Python library for offline reverse geocoding. It improves on an existing library called reverse_geocode developed by Richard Penman.

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Stargazers count: 9.3%
Forks count: 14.2%
Dependent repos count: 24.3%
Average: 24.9%
Dependent packages count: 51.6%
Last synced: 11 months ago

Dependencies

requirements.txt pypi
  • numpy >=1.11.0
  • scipy >=0.17.1
setup.py pypi
  • numpy >=1.11.0
  • scipy >=0.17.1