Datashader support for irregular triangular meshes allows large ADCIRC datasets to be rendered onscreen efficiently. This notebook shows an example of rendering the depth or M2 Amplitude from the EC2015 tidal database. Make possible by the EarthSim Project.
After the data loads (after ~20-30 seconds), click one of the zoom tools to see performant rendering on the fly....
import datashader as ds
import pandas as pd
import numpy as np
import holoviews as hv
from holoviews.operation.datashader import datashade, rasterize
import geoviews as gv
import palettable
from gridgeo.ugrid import ugrid
import netCDF4
hv.extension("bokeh")
# EC2015 data in netCDF form, accessed via OPeNDAP.
# Here we use a UGRID-ized version of http://tds.renci.org:8080/thredds/dodsC/DataLayers/Tides/ec2015_tidaldb/f53.nc.html
url='http://gamone.whoi.edu/thredds/dodsC/usgs/vault0/models/tides/ec2015/f53.ncml'
nc = netCDF4.Dataset(url)
# Use gridgeo to get mesh from UGRID compliant dataset
u = ugrid(nc)
# Select variable to plot.
z = nc['Amp'][0,:] # M2 amplitude
#z = nc['depth'][:] # water depth
v = np.vstack((u['nodes']['x'], u['nodes']['y'], z)).T
verts = pd.DataFrame(v, columns=['x','y','z'])
tris = pd.DataFrame(u['faces'].astype('int'), columns=['v0','v1','v2'])
cmap=palettable.cubehelix.perceptual_rainbow_16.mpl_colormap
%opts WMTS [width=700 height=400]
tiles = gv.WMTS('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg')
points = gv.operation.project_points(gv.Points(verts, vdims=['z']))
tiles * datashade(hv.TriMesh((tris, points)), cmap=cmap, aggregator=ds.mean('z'), normalization='linear', precompute=True)
%%opts Image [colorbar=True] (cmap=palettable.cubehelix.perceptual_rainbow_16.mpl_colormap)
%opts WMTS [width=700 height=400]
tiles = gv.WMTS('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg')
points = gv.operation.project_points(gv.Points(verts, vdims=['z']))
tiles * rasterize(hv.TriMesh((tris, points)), aggregator=ds.mean('z'), precompute=True)