import plotly.plotly as py
import numpy as np
import pandas as pd
import json
df = pd.read_csv('https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat', header=None)
df.head()
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | Goroka | Goroka | Papua New Guinea | GKA | AYGA | -6.081689 | 145.391881 | 5282 | 10 | U | Pacific/Port_Moresby |
1 | 2 | Madang | Madang | Papua New Guinea | MAG | AYMD | -5.207083 | 145.788700 | 20 | 10 | U | Pacific/Port_Moresby |
2 | 3 | Mount Hagen | Mount Hagen | Papua New Guinea | HGU | AYMH | -5.826789 | 144.295861 | 5388 | 10 | U | Pacific/Port_Moresby |
3 | 4 | Nadzab | Nadzab | Papua New Guinea | LAE | AYNZ | -6.569828 | 146.726242 | 239 | 10 | U | Pacific/Port_Moresby |
4 | 5 | Port Moresby Jacksons Intl | Port Moresby | Papua New Guinea | POM | AYPY | -9.443383 | 147.220050 | 146 | 10 | U | Pacific/Port_Moresby |
5 rows × 12 columns
The longitudes are in column 7 and the latitudes in column 6.
py.iplot(
dict(
data=[
dict(
type='scattergeo',
lon=df.ix[:,7],
lat=df.ix[:,6],
text=df.apply(lambda row: str(row[1])+' ('+str(row[4])+')'+'<br>'+str(row[3]), axis=1),
name='',
marker=dict(
opacity=0.4,
line=dict(
color='rgb(187,187,187)',
width=0.5
)
)
)
],
layout=dict(
title='Map of the world\'s airports',
titlefont=dict(
size=24
),
geo=dict(
projection=dict(
type='natural earth'
),
showcountries=True
)
)
),
validate=False,
filename='airport',
auto_open=False
)
See the full-screen version at: plot.ly/~etpinard/4288.embed
# Inject CSS styling in the NB
from IPython.display import display, HTML
display(HTML(open('../_custom.css').read()))