pytuflow.Grid.to_mesh#
- Grid.to_mesh(base_topology=None)#
Converts the grid to a
GridMeshobject, essentially converting the grid data structure into a mesh data structure. This can be useful for exporting into other formats that can only be done via a mesh class e.g. to aglTFfile.- Parameters:
base_topology (str | Grid | None, optional) –
The base topology to use for the mesh. It’s a good idea to specify a base topology if the grid is temporal or has multiple data types. If left as
None, the first static dataset found in the grid will be used as the base topology.If a string is provided, it is assumed to be a data type contained in the grid. For example, in a NetCDF grid, this might be
"max water level".If another
Gridobject is provided, it will be used as the base topology. The other grid should match the grid dimensions of the current grid. For example, theDEM_Zcheck file from TUFLOW can be used as a base topology for a NetCDF grid output file to provide the static ground elevation data and be used as the base mesh topology.- Returns:
The grid converted to a GridMesh object.
- Return type:
Examples
Convert a maximum water level grid to a mesh:
>>> from pytuflow import Grid >>> grid = Grid('/path/to/results/grid/Model_Max_h.tif') >>> mesh = grid.to_mesh()
Convert a temporal NetCDF grid to a mesh using the DEM_Z check file as the base topology:
>>> from pytuflow import NCGrid, Grid >>> res = NCGrid('/path/to/results/model_output.nc') >>> grid = Grid('/path/to/check/DEM_Z.tif') >>> mesh = res.to_mesh(base_topology=grid)