grid_show

To do:

To visulize grid data, e.g. raster objec(s)


hydro_raster.grid_show.hillshade(raster_obj, ax=None, figsize=None, azdeg=315, altdeg=45, vert_exag=1, cmap=None, blend_mode='overlay', alpha=1, scale_ratio=1)

Draw a hillshade map

hydro_raster.grid_show.make_gif(output_file, obj_list=None, header=None, array_3d=None, time_str=None, breaks=None, fig_names=None, duration=0.5, delete=False, **kwargs)

Create animation of gridded data

Parameters:
  • mask_header – (dict) header file provide georeference of rainfall mask

  • start_date – a datetime object to give the initial date and time of rain

  • duration – duration for each frame (seconds)

  • cellsize – sclar (meter) the size of rainfall grid cells

hydro_raster.grid_show.make_mp4(output_file, obj_list=None, header=None, array_3d=None, time_str=None, breaks=None, fig_names=None, delete=False, fps=10, **kwargs)

Create a video file based on a series of grids

Parameters:
  • obj_list – a list of Raster objects

  • header – a header dict providing georeference the grid [not necessary if obj_list was given]

  • array_3d – a 3D numpy array storing grid values for each timestep (in 1st dimension), [not necessary if obj_list was given]

  • time_str – a list of string to show time information for each frame

hydro_raster.grid_show.mapshow(raster_obj=None, array=None, header=None, ax=None, figname=None, figsize=None, dpi=300, title=None, cax=True, cax_str=None, scale_ratio=1, **kwargs)

Display raster data without projection

Parameters:
  • raster_obj – a Raster object

  • array – to make Raster object if raster_obj is not given

  • header – to make Raster object if raster_obj is not given

  • figname – the file name to export map, if figname is empty, then the figure will not be saved

  • figsize – the size of map

  • dpi – The resolution in dots per inch

  • covers (vmin and vmax define the data range that the colormap) –

  • **kwargs – keywords argument of function imshow

hydro_raster.grid_show.plot_shape_file(shp_file, figsize=None, ax=None, color='r', linewidth=0.5, edgecolor='k', facecolor='none', alpha=1, **kw)

plot a shapefile of polygons or polylines

Parameters:
  • shp_file (string) – shapefile name.

  • figsize (tuple of two int values, optional) – set figsize. The default is None.

  • ax (axis object, optional) –

  • color (string or matplotlib color object, The default is 'r') –

  • linewidth (scalar, optional) – Set linewidth. The default is 0.5.

  • edgecolor (string or matplotlib color object, optional) – Set edgecolor of polygon. The default is ‘k’.

  • facecolor (TYPE, optional) – Set facecolor of polygon. The default is ‘none’.

  • alpha (scalar value between 0 to 1, optional) – Set transparent rate of polygon. The default is 1.

  • **kw (other matplotlib plot arguments) –

Returns:

  • fig (figure handle)

  • ax (axis handle)

hydro_raster.grid_show.rankshow(raster_obj=None, array=None, header=None, figname=None, figsize=None, dpi=200, ax=None, color='Blues', breaks=[0.2, 0.3, 0.5, 1, 2], title=None, legend_kw=None, scale_ratio=1, alpha=1, **kwargs)

Display water depth map in ranks defined by breaks

Parameters:
  • breaks – list of values to define rank. Array values lower than the first break value are set as nodata.

  • color – color series of the ranks

  • ylabelrotation – scalar giving degree to rotate yticklabel

  • legend_kw – dict, keyword arguments to set legend. A colobar rather than a legend be displayed if legend_kw is None.

  • **kwargs – keywords argument of function imshow

Example

rankshow(figname=None, figsize=None,

dpi=200, ax=None, color=’Blues’, breaks=[0.2, 0.3, 0.5, 1, 2], legend_kw={‘loc’:’upper left’, ‘facecolor’:None,

‘fontsize’:’small’, ‘title’:’depth(m)’, ‘labelspacing’:0.1},

scale_ratio=1, alpha=1)

hydro_raster.grid_show.vectorshow(obj_x, obj_y, figname=None, figsize=None, dpi=300, ax=None, scale_ratio=1, **kwargs)

plot velocity map of U and V, whose values stored in two raster objects seperately