kotoro
Joined: 15/05/2022 20:34:57
Messages: 3
Offline
|
I am trying to find a way to get ISO3166-2 (and failing that FIPS10-4) codes for as many of the admin1 codes as I can.
Using the dump files to get a list of lat/lng for adm1 records and querying the
http://api.geonames.org/countrySubdivisionJSON endpoint doesn't always return the expected structure.
For example, geonameid 11205389 has latitude 18.177 and longitude -63.09161.
but requesting on http://api.geonames.org/countrySubdivisionJSON?lat=18.177&lng=-63.09161&lang=en&level=1&radius=100&username=<myusername>
returned this json structure: {'distance': 0, 'countryCode': 'AI', 'countryName': 'Anguilla'}
instead of something like this:
{'codes': [{'code': '06', 'level': '1', 'type': 'ISO3166-2'}],
'adminCode1': '06',
'distance': 0,
'countryCode': 'AD',
'countryName': 'Andorra',
'adminName1': 'Sant JuliĆ de Loria'}
I'm using the location specified within the source data, so why isn't it returning the information for that record?
Is there a better way to get the iso and fips codes for these records? Something that doesnt' require consuming credits on geonames would be even better. (I'm running things in python, so something on github or pypi is strongly preferred)
|