Geo

Geo / ReverseGeocoder / 0.1.0

README.md

Introduction

An algorithm for offline reverse geocoding. Besides city/town and country code, this algorithm also returns the nearest latitude and longitude and also administrative regions 1 and 2 for any given latitude and longitude coordinates.

Input:

  • (Required): lat: Latitude
  • (Required): lon: Longitude

Output:

  • name: city name
  • cc: country code
  • lat: latitude for the nearest region
  • lon: longitude for the nearest region
  • admin1: administration level 1 (eg. State for U.S)
  • admon2: administration level 2 (eg. County for U.S)

Examples

Example 1.

  • Parameter 1: Latitude of a place in Seattle
  • Parameter 2: Longitude of a place in Seattle
{
  "lat": 47.610518,
  "lon": -122.342829
}

Output:

{
  "admin1": "Washington",
  "admin2": "King County",
  "cc": "US",
  "lat": "47.60621",
  "lon": "-122.33207",
  "name": "Seattle"
}

Example 2.

  • Parameter 1: Latitude of a place in London
  • Parameter 2: Longitude of a place in London
{
  "lat": 51.511766,
  "lon": -0.092568
}

Output:

{
  "admin1": "England",
  "admin2": "Greater London",
  "cc": "GB",
  "lat": "51.51279",
  "lon": "-0.09184",
  "name": "City of London"
}

Credits

For more information, please refer to: https://github.com/thampiman/reverse-geocoder