forked from 0x2620/oxjs
improved geodata and tools
This commit is contained in:
parent
4d9a8537ef
commit
912f2121a4
47 changed files with 682294 additions and 3535 deletions
19
tools/geo/py/geonames.py
Normal file
19
tools/geo/py/geonames.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import ox
|
||||
from geo import read_json, read_table
|
||||
|
||||
geo = {
|
||||
'keys': read_json('../json/oxjs.org/geonames.keys.json')
|
||||
#'levels': read_json('../json/oxjs.org/levels.json')
|
||||
}
|
||||
|
||||
def get_countries():
|
||||
return get_data('country', 'countryInfo', 'ISO')
|
||||
|
||||
def get_data(type, file, sort_key):
|
||||
keys = geo['keys'][type]['geonames.org']
|
||||
sort = lambda x: x[sort_key]
|
||||
data = read_table('http://download.geonames.org/export/dump/' + file + '.txt', keys, sort=sort)
|
||||
return data
|
||||
|
||||
def get_languages():
|
||||
return get_data('language', 'iso-languagecodes', 'ISO_639-3')
|
||||
Loading…
Add table
Add a link
Reference in a new issue