Versions Compared

Key

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

De hoogte van het 2D-grid kan met twee functies bepaald:

...

altitude_constant: Ken een constante hoogte aan de rekencellen. Dit kan zowel op de faces (cellen) als nodes (hoekpunten) gedaan worden, al zal dat in praktijk niet uitmaken bij een constante hoogte.

de gridcellen kan worden afgeleid uit een maaiveldhoogteraster via de functie ‘mesh2d_altitude_from_

...

Code Block
Method to determine level within cell or on nodes. The values are determined by
applying a statistic to the pixels within the cell bounds or around the node.

In case of the option 'node' Voronoi polygons are drawn around the nodes. These cells
are cut of at the edges of the the grid. This option might take a bit longer, since
all the polygons need to be drawn and clipped at the edges.

In case of msising values, which can occur:
- due to no-data parts in the grid that is sampled
- when the cell sizes within which the altitude is determined is smaller than a raster
  pixel.
The missing data can be filled.

Parameters
----------
rasterpath : str
	Path to raster
where : str
	Locations where the altitude is determined. Can be on the faces, so within the
	cell boundaries, or node, on the cell edged. Default: 'face'
stat : str
	Statistic to determined from values within polygon bounds. A string is required
	that describes a function that is known by numpy, such as 'mean' or 'max',
	without any further arguments (quantile is not possible, since we'd need to
	specify which quantile). Default: 'mean'
missing : str
	How to fill the missing values.
	- default: No filling, the missing values will have a NaN-value in the grid
	- nearest: Fill the missing data with the nearest cell value that has a value
	- interpolation: Interpolate the missing data with cell values that are present
	 Default: 'default'

Beide functies zijn een ‘method’ van de class Mesh2D.

Met de functie set_missing_z_value kan een waarde worden gespecificeerd voor de cellen waar geen waarde bekend is. Deze waarde wordt in de mdu bij BedLevUni ingevuldraster’:

Code Block
def mesh2d_altitude_from_raster(
    network,
    rasterpath,
    where: RasterStatPosition = "face",
    stat="mean",
    fill_option: FillOption = "fill_value",
    fill_value=None,
):
    """
    Method to determine level of nodes

    This function works faster for large amounts of cells, since it does not
    draw polygons but checks for nearest neighbours (voronoi) based
    on interpolation.

    Note that the raster is not clipped. Any values outside the bounds are
    also taken into account.
    
    Arguments:
      network: network object containing the mesh
      rasterpath: path to the rasterfile containing elevations
      where: 'face' or 'node'; default = face
      stat: rasterstat statistic to be used (default = mean)
      fill_option: "fill-value", 'nearest', or 'interpolate'. Fill missing cells with a constant value, by nearest-neighbour interpolation, or by linear interpolation.
      fill_value: value to fill missing cells with (also needed for interpolation in case that fails)
    """

Een voorbeeld van een toepassing wordt hieronder getoond. De gemiddelde hoogte van een gridcell wordt toegekend aan de mesh ‘faces’. Waar data mist, wordt 15 m ingevuld.

mesh.mesh2d_altitude_from_raster(network, "../tests/data/rasters/AHN_2m_clipped_filled.tif", "face", "mean", fill_value=15)

Merk op dat de keuze voor de hoogtebepaling op de nodes of faces niet los gezien kan worden van de rekeninstellingen in het mdu-bestand. Zie de handleiding van D-Hydro zoals die wordt meegeleverd met de installatie.