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_raster’:
Code Block |
---|
def mesh2d_altitude_from_raster(self, rasterpath, where='face', stat='mean', missing='default'): network, """ rasterpath, Method towhere: determineRasterStatPosition 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= "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. Parameters ---------- rasterpath : strArguments: Path to raster where network: strnetwork Locations whereobject containing the altitudemesh is determined. Can be on the faces,rasterpath: sopath withinto the rasterfile containing elevations cell boundaries, or node, on the cell edged. Default where: 'face' or 'node'; default = stat :face str stat: rasterstat Statisticstatistic to determinedbe fromused values(default within polygon bounds. A string is required that describes a function that is known by numpy, such as 'mean'= mean) fill_option: "fill-value", 'nearest', or 'maxinterpolate',. withoutFill anymissing cells with a constant value, by further arguments (quantile is not possible, since we'd need to specify which quantile)nearest-neighbour interpolation, or by linear interpolation. Default: 'mean' missing : str How fill_value: value 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.
...
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.