Skip to content

Instantly share code, notes, and snippets.

@alexprengere
Last active April 30, 2020 06:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexprengere/c54d706d659653049863355b8bb2ac3b to your computer and use it in GitHub Desktop.
Save alexprengere/c54d706d659653049863355b8bb2ac3b to your computer and use it in GitHub Desktop.
Check airports not connected to a big city
from neobase import NeoBase
N = NeoBase()
for key in N:
N.set(key, city_codes=set(N.get(key, "city_code_list")))
for key in sorted(N):
if "A" not in N.get(key, "location_type"):
continue
if N.get(key, "page_rank") is None: # to speed things up, but this could be removed
continue
city_codes = N.get(key, "city_codes")
for dist, other in N.find_near(key, radius=60):
if "C" not in N.get(other, "location_type"):
continue
if N.get(other, "iata_code") in city_codes:
continue
if N.get(other, "page_rank") is None:
continue
if N.get(other, "page_rank") <= N.get(key, "page_rank") * 50:
continue
print(
"{0}[{1:.3f}] should have {2}[{3:.3f}] in its city list {4}:"
" dist {5:.1f}km -- {6}[{7}] => {8}[{9}]".format(
N.get(key, "iata_code"),
N.get(key, "page_rank"),
N.get(other, "iata_code"),
N.get(other, "page_rank"),
list(city_codes),
dist,
N.get(key, "name"),
N.get(key, "country_code"),
N.get(other, "name"),
N.get(other, "country_code"),
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment