symerio / pgeocode

Postal code geocoding and distance calculation
https://pgeocode.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
238 stars 58 forks source link

Cannot create nominatim for country codes AS, LT, VA #17

Closed bcipolli closed 4 years ago

bcipolli commented 5 years ago

I have a set of zip codes that I need to decode to countries. To do so, I plan to query each nominatim and return any country where a match is found.

In trying to instantiate each nominatum, I received an error:

import pgeocode
nomis = {cc: pgeocode.Nominatim(cc) for cc in pgeocode.COUNTRIES_VALID}

When investigating:

for cc in pgeocode.COUNTRIES_VALID:
     try:
         pgeocode.Nominatim(cc)
     except Exception as ex:
         print(cc, ex)

I get:

AS No numeric types to aggregate
LT sequence item 1: expected str instance, float found
VA No numeric types to aggregate

Suggest either investigating, or dropping from the valid countries list. Thanks!

rth commented 5 years ago

Thanks @bcipolli ! Sound like a bug. Do you want to investigate ? :) A full traceback would also be helpful.

Initially I wasn't keen on running unit tests for all countries, as that would mean downloading all datasets for each CI run, but given that the datasets also get updated with time, maybe there is no way around it.

bcipolli commented 5 years ago

@rth Three different issues; would you prefer 3 tickets?

Lemme know how you'd like to solve, I can likely push up a PR for code changes.

rth commented 4 years ago

Sorry for late reply. Essentially we need to add logic here (possibly as a separate function) to fix incorrect data for these countries. If you are still interested don't hesitate to make a PR.