Skip to content

Instantly share code, notes, and snippets.

@brinnaebent
Created November 6, 2020 22:01
Show Gist options
  • Save brinnaebent/01c0bf5e4b20ae60e254241d2bc62bd8 to your computer and use it in GitHub Desktop.
Save brinnaebent/01c0bf5e4b20ae60e254241d2bc62bd8 to your computer and use it in GitHub Desktop.
# Separate Latitude and Longitude, Re-format, Clean
df = pd.DataFrame()
df['lat'] = pd.to_numeric(filterdata['latitude'], errors='coerce') # Change to filterdata here
df['long'] = pd.to_numeric(filterdata['longitude '], errors='coerce') # Change to filterdata here
df = df.dropna()
# Set Figure and Font Sizes
fig = plt.figure(figsize=(20,10))
plt.rcParams.update({'font.size': 20})
# Create Map Projection
wmap = Basemap(projection='mill', llcrnrlat = -90, urcrnrlat = 90, llcrnrlon = -180, urcrnrlon = 180, resolution='c')
wmap.drawcoastlines()
# Convert Lat/Long to arrays for plotting
latarray = np.array(df['lat'])
longarray = np.array(df['long'])
# Plot Map!
wmap.scatter(longarray, latarray, latlon=True, color='lime', s=20)
plt.title('Reported UFO Sightings 2014-2016')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment