Last active
July 10, 2017 16:51
-
-
Save saliksyed/a17f558265b23125ad016b863388f66b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from mpl_toolkits.basemap import Basemap | |
| import matplotlib.pyplot as plt | |
| import json | |
| # create new figure, axes instances. | |
| # we specify specific sizes for the figure to make it bigger | |
| # DPI is "Dots per inch" -- it's used in the printing world | |
| # The reason we specify the DPI instead of raw pixels is because | |
| # we want the text to be consistently scaled. | |
| my_dpi = 75 | |
| fig = plt.figure(figsize=(3600/my_dpi, 1800/my_dpi), dpi=my_dpi) | |
| m = Basemap() | |
| m.drawcoastlines() | |
| data = json.loads(open("africa_china_airports.json","r").read()) | |
| lats = [] | |
| lons = [] | |
| for airport_id in data: | |
| lats.append(data[airport_id]["latitude"]) | |
| lons.append(data[airport_id]["longitude"]) | |
| # add scatter points to the graph: | |
| m.scatter(lons, lats, latlon=True) | |
| plt.savefig('map.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment