Python | Reverse Geocoding to get location on a map using geographic coordinates
Reverse geocoding is the process of finding a place or a location address from a given pair of geographic coordinates(latitude and longitude).
Modules needed:
reverse_geocoder: A Python library for offline reverse geocoding. Pprint: A module which helps to "pretty-print" any arbitrary python data structure.
Installation:
The modules can be easily installed using pip.
pip install reverse_geocoder pip install pprint
Examples:
Input : (36.778259, -119.417931)
Output :
[OrderedDict([('lat', '36.72384'),
('lon', '-119.45818'),
('name', 'Minkler'),
('admin1', 'California'),
('admin2', 'Fresno County'),
('cc', 'US')])]
Input : (28.644800, 77.216721)
Output :
[OrderedDict([('lat', '28.63576'),
('lon', '77.22445'),
('name', 'New Delhi'),
('admin1', 'NCT'),
('admin2', 'New Delhi'),
('cc', 'IN')])]
Below is the implementation:
# Python3 program for reverse geocoding. # importing necessary libraries import reverse_geocoder as rg import pprint def reverseGeocode(coordinates): result = rg.search(coordinates) # result is a list containing ordered dictionary. pprint.pprint(result) # Driver function if __name__=="__main__": # Coorinates tuple.Can contain more than one pair. coordinates =(28.613939, 77.209023) reverseGeocode(coordinates) |
chevron_right
filter_none
Output:
[OrderedDict([('lat', '28.63576'),
('lon', '77.22445'),
('name', 'New Delhi'),
('admin1', 'NCT'),
('admin2', 'New Delhi'),
('cc', 'IN')])]
References:
https://pypi.org/project/reverse_geocoder/
https://www.latlong.net/
Recommended Posts:
- Python | Calculate geographic coordinates of places using google geocoding API
- Python script to open a Google Map location on clipboard
- Statistical Functions in Python | Set 1 (Averages and Measure of Central Location)
- Python | Get a google map image of specified location using Google Static Maps API
- Python list | reverse()
- Reverse words in a given String in Python
- Python | Reverse Slicing of given string
- Reverse string in Python (5 different ways)
- Python | Reverse a numpy array
- Python | Reverse each word in a sentence
- Python | Reverse an array upto a given position
- Python | Reverse sign of each element in given list
- Python | Reverse each tuple in a list of tuples
- Python Slicing | Reverse an array in groups of given size
- Python | Play a video in reverse mode using OpenCV
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



