Created
November 6, 2020 22:05
-
-
Save brinnaebent/2b1a8aaad79b1843007bc1189f0ccd89 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
def plot_map_gif(year): | |
filterdata = data[data.year == year] | |
df = pd.DataFrame() | |
df['lat'] = pd.to_numeric(filterdata['latitude'], errors='coerce') | |
df['long'] = pd.to_numeric(filterdata['longitude '], errors='coerce') | |
df = df.dropna() | |
fig = plt.figure(figsize=(20,10)) | |
plt.rcParams.update({'font.size': 20}) | |
wmap = Basemap(projection='mill', llcrnrlat = -90, urcrnrlat = 90, llcrnrlon = -180, urcrnrlon = 180, resolution='c') | |
wmap.drawcoastlines() | |
latarray = np.array(df['lat']) | |
longarray = np.array(df['long']) | |
wmap.scatter(longarray, latarray, latlon=True, color='lime', s=20) | |
plt.title(('Reported UFO Sightings: ' + str(year))) | |
fig.canvas.draw() | |
image = np.frombuffer(fig.canvas.tostring_rgb(), dtype='uint8') | |
image = image.reshape(fig.canvas.get_width_height()[::-1] + (3,)) | |
return image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment