pythongeocode

Is there a way to change the language of Python's geocoder/geopy


There are 2 packages i'm using.

  1. geocoder
import geocoder
geocoder.osm([31.107, 103.146], method='reverse')

Output:

<[OK] Osm - Reverse [卧龙镇, 汶川卧龙特别行政区, 汶川县, 阿坝藏族羌族自治州, 四川省, 中国]>
  1. geopy
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="http")
location = geolocator.reverse("31.107, 103.146")
print(location.address)

Output:

卧龙镇, 汶川卧龙特别行政区, 汶川县, 阿坝藏族羌族自治州, 四川省, 中国

Is there any way to change this to English on Python without manually searching it up? I just need the name of the country.

Nothing in either documentation says anything about switching the language to English.

I've tried using google translate packages, but those get blocked (sometimes like the geocoders themselves).


Solution

  • pass language='en' to geolocator.reverse

    location = geolocator.reverse("31.107, 103.146", language="en")