Python Forum
Issue with geolocator = Nominatim
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue with geolocator = Nominatim
#1
Hey guys,

Hoping someone can explain the issue I'm having with Geolocator...it was working fine yesterday, but now when I run the cell it is coming back with Gateway 502 error. Attached below is the code and error message.

address = 'Chicago, IL, USA'

geolocator = Nominatim(user_agent="class-app")
location = geolocator.geocode(address)
latitude = location.latitude
longitude = location.longitude
print('The geographical coordinate of Chicago are {}, {}.'.format(latitude, longitude))
Error:
AdapterHTTPError Traceback (most recent call last) /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/geopy/geocoders/base.py in _call_geocoder(self, url, callback, timeout, is_json, headers) 359 if is_json: --> 360 result = self.adapter.get_json(url, timeout=timeout, headers=req_headers) 361 else: /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/geopy/adapters.py in get_json(self, url, timeout, headers) 372 def get_json(self, url, *, timeout, headers): --> 373 resp = self._request(url, timeout=timeout, headers=headers) 374 try: /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/geopy/adapters.py in _request(self, url, timeout, headers) 403 status_code=resp.status_code, --> 404 text=resp.text, 405 ) AdapterHTTPError: Non-successful status code 502 The above exception was the direct cause of the following exception: GeocoderServiceError Traceback (most recent call last) <ipython-input-52-b44a620f75c6> in <module> 2 3 geolocator = Nominatim(user_agent="class-app") ----> 4 location = geolocator.geocode(address) 5 latitude = location.latitude 6 longitude = location.longitude /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/geopy/geocoders/nominatim.py in geocode(self, query, exactly_one, timeout, limit, addressdetails, language, geometry, extratags, country_codes, viewbox, bounded, featuretype, namedetails) 292 logger.debug("%s.geocode: %s", self.__class__.__name__, url) 293 callback = partial(self._parse_json, exactly_one=exactly_one) --> 294 return self._call_geocoder(url, callback, timeout=timeout) 295 296 def reverse( /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/geopy/geocoders/base.py in _call_geocoder(self, url, callback, timeout, is_json, headers) 376 return callback(result) 377 except Exception as error: --> 378 self._adapter_error_handler(error) 379 raise 380 /opt/conda/envs/Python-3.7-main/lib/python3.7/site-packages/geopy/geocoders/base.py in _adapter_error_handler(self, error) 390 self._geocoder_exception_handler(error) 391 exc_cls = ERROR_CODE_MAP.get(error.status_code, GeocoderServiceError) --> 392 raise exc_cls(str(error)) from error 393 else: 394 self._geocoder_exception_handler(error) GeocoderServiceError: Non-successful status code 502
Please advise what I am doing wrong.

Thank you.
Reply
#2
probably some temporary problem with Nominatim
right now, if you try the examples here:
https://nominatim.org/release-docs/develop/api/Search/

the xml link return 502 Bad Gateway
https://nominatim.openstreetmap.org/sear...sdetails=1


while the JSON link example works
https://nominatim.openstreetmap.org/sear...ygon_svg=1
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
OK, now it works, incl. your code
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
(Dec-04-2020, 04:57 PM)buran Wrote: OK, now it works, incl. your code

Thanks for the help! Just learning all of these things.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] [Nominatim] How to get "town" from reply? Winfried 0 1,891 Aug-27-2018, 05:36 AM
Last Post: Winfried

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020