Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

scrollbar

To add the bathymetry, we will use employ the Gebco dataset data set, as used in delft Delft dashboard. We start by using the following lineThe following code retrieves the bathymetry data from the Gebco data set using the extent of our grid. The coordinate system EPSG code is required because the data set uses a specific (different) coordinate system.

Code Block
languagepy
titleGet bathymetry data
bathymetryData = GetGebcoBathymetryData(xOffset, yOffset, xOffset + gridWidth, yOffset + gridHeigthgridHeight, 3857)

Here we retrieve the bathymetry data from the gebco dataset using the extent of our grid and the coordinate system EPSG code. This is needed because the dataset uses a specific (different) coordinate system.

 

EPSGCode)

Next, The next step is to remove the cells that are located on land will be removed. We can determine this by using our bathymetry data. Add and run the following line to remove This can be determined from the bathymetry data. The CleanupLandCells method removes all land cells that have a depth above -2z coordinate larger than a certain value. In our case, above sea level, so z > 0.

Code Block
languagepy
titleRemove land cells
CleanupLandCells(fmModel, bathymetryData, -20)

The grid should now look something like this:

Image Removed

 

be trimmed along the coastline.

Image Added

Then, the bathymetry (defined as elevation, z coordinate, at the vertex) will be added to the model. This is done by first declaring a variable values as a list. Then, we loop trough the vertices of the grid, calling the function GetGebcoBathymetryValueFor  ( Image Added ) to obtain the elevation at each vertex, which we then add to the list values, previously declared. Finally, we assign the bathymetry values to the model by using the SetValues method of the Bathymetry property of the model.The last step is to add the bathymetry to the model (defined as depth at the vertex) with the following lines :

Code Block
languagepy
titleRemove land cellsAdd bathymetry to model
values = []
for vertex in fmModel.Grid.Vertices :
    values.append(GetGebcoBathymetryValueFor(vertex.CoordinateValue, 3857, bathymetryData))

fmModel.Bathymetry.SetValues(values)

First we declare a variable called values as a list. Then we continue by looping trough the vertices of the grid and calling the function "GetGebcoBathymetryValueFor"  to get the depth value on the location of the vertex and adding it to the list. Finally we add the bathymetry values to the model by using the SetValues method on the bathymetry property of the model. This should result in the following :

The bathymetry just defined can be seen by double clicking on the corresponding item of the project explorer panel.

Image Added

Note: The icon Image Added indicates functions that you might find interesting to see how they have been built. You can do this by opening the corresponding library (another normal script python file on its own) in the toolbox and checking the code which defines the function or method you are interested in.Image Removed

scrollbar