Skip to content

Instantly share code, notes, and snippets.

@dnomadb
Created February 3, 2015 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnomadb/bf744521cb97a9598c4d to your computer and use it in GitHub Desktop.
Save dnomadb/bf744521cb97a9598c4d to your computer and use it in GitHub Desktop.
import os, rasterio
import matplotlib.pyplot as plot
basedir = '/Users/dnomadb/Documents/pwat_hrrr/'
savedir = '/Users/dnomadb/Documents/pwat_hrrr_pngs/'
with rasterio.drivers():
for i in os.listdir(basedir):
if i.split('.')[-1] == 'grib':
print i
# fig = figure()
with rasterio.open(os.path.join(basedir, i), 'r') as src:
fig = plot.imshow(src.read_band(1), cmap='YlGnBu_r')
plot.axis('off')
fig.axes.get_xaxis().set_visible(False)
fig.axes.get_yaxis().set_visible(False)
plot.savefig(os.path.join(savedir, i.replace('.grib', '.png')),bbox_inches='tight')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment