Browse Source

Tighten up frame and add tracks as single list for performance

master
Nathan Bergey 5 years ago
parent
commit
67b2b5dc13
  1. BIN
      tornados_us.png
  2. 33
      tornados_us.py

BIN
tornados_us.png

Before

Width: 2048  |  Height: 1536  |  Size: 865 KiB

After

Width: 2560  |  Height: 1475  |  Size: 1.4 MiB

33
tornados_us.py

@ -13,8 +13,8 @@ import shapely.geometry as sgeom
proj = ccrs.AlbersEqualArea(
central_longitude=-95,
central_latitude=40,
central_longitude=-93,
central_latitude=35,
)
water_blue = "#7ebfd4"
@ -87,11 +87,11 @@ def read_data():
return tornados
def draw_map(data):
fig = plt.figure(frameon=False)
ax = fig.add_subplot(111, projection=proj)
def draw_map(lons, lats):
fig = plt.figure(frameon=False, figsize=(8, 4.61))
ax = fig.add_axes([0, 0, 1, 1], projection=proj)
ax.background_patch.set_facecolor(water_blue)
ax.set_extent([-125, -65, 20, 50], ccrs.Geodetic())
ax.set_extent([-122, -65, 20, 50], ccrs.Geodetic())
ax.add_feature(land, facecolor="#f0f0f0")
ax.add_feature(rivers, edgecolor=water_blue)
ax.add_feature(lakes, facecolor=water_blue)
@ -99,17 +99,22 @@ def draw_map(data):
ax.add_feature(countries, edgecolor="grey", linewidth=0.2, alpha=0.6, dashes='--')
ax.add_feature(states, edgecolor="grey", linewidth=0.2, alpha=0.4, dashes='--')
for i, t in enumerate(data):
print(i)
if t.elon < 0:
ax.plot([t.slon, t.elon], [t.slat, t.elat], 'r', lw=0.3, transform=ccrs.Geodetic())
else:
ax.plot([t.slon, t.slon], [t.slat, t.slat], 'r', lw=0.3, transform=ccrs.Geodetic())
ax.plot(lons, lats, 'r', lw=0.2, alpha=0.7, transform=ccrs.Geodetic())
fig.tight_layout()
ax.axis('off')
plt.savefig("tornados_us.png", dpi=320)
if __name__ == '__main__':
ts = read_data()
draw_map(ts)
lons = []
lats = []
for t in ts:
if t.elon < 0:
lons.append(t.slon)
lons.append(t.elon)
lons.append(None)
lats.append(t.slat)
lats.append(t.elat)
lats.append(None)
draw_map(lons, lats)
Loading…
Cancel
Save