Skip to content

Instantly share code, notes, and snippets.

@saliksyed
Created July 10, 2017 13:10
Show Gist options
  • Save saliksyed/fcd846526bb5d129f2a9a089b1337b0a to your computer and use it in GitHub Desktop.
Save saliksyed/fcd846526bb5d129f2a9a089b1337b0a to your computer and use it in GitHub Desktop.
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())
lons = []
lats = []
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, marker='D',color='m')
plt.savefig('map.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment