[GIS] Find country from GPS coordinates, offline using python

gdalgpspythonreverse-geocoding

I'm aware that there are several similar questions already but I have been searching for days and not been able to solve my problem:

All solutions I've found require GDAL, which I have not been able to install (even doing all the environment variables tweaking etc.) except by using OSGEO4W, which allows me to use osgeo, but only in its own shell, rather than in the shell I use for everything else.

I have the country shapefiles, I have the shapely package. Is there a way to do this without GDAL? (or as an alternative, an easy way to get GDAL packages in my own shell?)

Best Answer

I finally found what I was looking for: a package called reverse_geocode. It can be installed with pip.

>>>> import reverse_geocoder 
>>>> coordinates = (-37.81, 144.96), (31.76, 35.21)
>>>> reverse_geocode.search(coordinates)
[{'city': 'Melbourne', 'code': 'AU', 'country': 'Australia'},
 {'city': 'Jerusalem', 'code': 'IL', 'country': 'Israel'}]

Information about the function can be found here: https://pypi.org/project/reverse_geocoder/