XLON_matrix, YLAT_matrix = numpy.meshgrid(LON_vector, LAT_vector) %pylab inline import os, os.path import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap from pygaarst import raster viirsh5 = 'tests/data/SVDNB_npp_d20130725_t2022157_b09030_cspp_dev.h5' viirsband = raster.HDF5(viirsh5) print viirsband.bandname print viirsband.dirname viirsdataset = viirsband.dataobj['All_Data/VIIRS-DNB-SDR_All/Radiance'] viirsdataset.shape print viirsband.dataobj.attrs['N_GEO_Ref'][0][0] print viirsband.geofilepath viirsband.lats viirsband = raster.HDF5(viirsh5, geofilepath="[path/to/georeference/file.h5]") fig = plt.figure(1, figsize=(18, 15)) plt.imshow(viirsdataset, cmap='bone', aspect='equal') plt.figure(2, figsize=(18, 15)) plt.pcolormesh(viirsband.lons, viirsband.lats, viirsdataset, cmap='bone') viirsdata = viirsdataset[:, -2000:] lat = viirsband.lats[:, -2000:] lon = viirsband.lons[:, -2000:] fig = plt.figure(3, figsize=(18, 15)) m = Basemap(width=1800000, height=1200000, resolution='i', projection='aea', lat_1=55., lat_2=75., lat_0=65., lon_0=-150.) m.drawrivers(color='lightskyblue', zorder=20) m.drawcoastlines(color='lightskyblue', zorder=20) m.drawcoastlines(color='.08') m.drawcountries(linewidth=1.5, color='chocolate') m.fillcontinents(lake_color='lightskyblue', color='snow') m.drawmapboundary(fill_color='lightskyblue') # transform coordinates from lat/lon to map coordinates xx, yy = m(lon, lat) m.pcolormesh(xx, yy, viirsdata, cmap='bone', zorder=15) m.drawmeridians(np.arange(-180, -50, 10), labels=[0, 0, 1, 1]) m.drawparallels(np.arange(30, 80, 5), labels=[1, 1, 0, 0]) fig = plt.figure(4, figsize=(18, 15)) m = Basemap(width=600000, height=400000, resolution='f', projection='aea', lat_1=55., lat_2=75., lat_0=65., lon_0=-150.) m.drawrivers(color='lightskyblue', zorder=20) m.drawcoastlines(color='lightskyblue', zorder=20) m.drawcoastlines(color='.08') m.drawcountries(linewidth=1.5, color='chocolate') m.fillcontinents(lake_color='lightskyblue', color='snow') m.drawmapboundary(fill_color='lightskyblue') xx, yy = m(lon, lat) m.pcolormesh(xx, yy, viirsdata, cmap='bone', zorder=15) m.drawmeridians(np.arange(-180, -50, 5), labels=[0, 0, 1, 1]) m.drawparallels(np.arange(30, 80, 5), labels=[1, 1, 0, 0]) rgbgeotiff = os.path.join('tests/data/', 'LC80680152013194_754_crop2.tiff') ls = raster.GeoTIFF(rgbgeotiff) print type(ls.data) img = np.rollaxis(ls.data, 0, 3) fig = plt.figure(5, figsize=(18, 15)) plt.imshow(img) ls.proj4 ls.projection print ls.data.shape print ls.filepath ls.simpleplot() # plots each band in small fig = plt.figure(6, figsize=(18, 15)) plt.imshow(ls.data[0,:,:], cmap='bone') fig = plt.figure(7, figsize=(18, 15)) plt.pcolormesh(ls.data[0,:,:], cmap='bone')