hydromt_sfincs.workflows.merge_dataarrays#
- hydromt_sfincs.workflows.merge_dataarrays(da1: DataArray, da2: DataArray, offset: DataArray | float | None = None, min_valid: float | None = None, max_valid: float | None = None, gdf_valid: GeoDataFrame | None = None, buffer_cells: int = 0, merge_method: str = 'first', reproj_method: str = 'bilinear', interp_method: str = 'linear') DataArray [source]#
Return merged data from two data arrays.
Valid cells of da2 are merged with da1 according to merge_method. Valid cells are based on its nodata value; the min_valid-max_valid range; and the gd_valid region.
If buffer > 0, values at the interface between both data arrays are interpolate to create a smooth surface.
If offset is provided, a (spatially varying) offset is added to the second dataset to convert the vertical datum before merging.
- Parameters:
da1 (xr.DataArray) – Data arrays to be merged.
da2 (xr.DataArray) – Data arrays to be merged.
offset (xr.DataArray, float, optional) – Dataset with spatially varying offset or float with uniform offset
min_valid (float, optional) – Range of valid values for da2 - only valid cells are not merged. Note: applied after offset!
max_valid (float, optional) – Range of valid values for da2 - only valid cells are not merged. Note: applied after offset!
gdf_valid (gpd.GeoDataFrame, optional) – Geometry of the valid region for da2
buffer_cells (int, optional) – Buffer (number of cells) around valid cells in da1 (if merge_method=’first’) or da2 (if merge_method=’last’) where values are interpolated to create a smooth surface between both datasets, by default 0.
merge_method ({'first','last', 'mean', 'max', 'min'}, optional) – merge method, by default ‘first’: * first: use valid new where existing invalid * last: use valid new * mean: use mean of valid new and existing * max: use max of valid new and existing * min: use min of valid new and existing
reproj_method ({'bilinear', 'cubic', 'nearest', 'average', 'max', 'min'}) – Method used to reproject the offset and second dataset to the grid of the first dataset, by default ‘bilinear’. See
rasterio.warp.reproject()
for more methodsinterp_method – Method used to interpolate the buffer cells, by default ‘linear’.
{'linear' – Method used to interpolate the buffer cells, by default ‘linear’.
'nearest' – Method used to interpolate the buffer cells, by default ‘linear’.
'rio_idw'} – Method used to interpolate the buffer cells, by default ‘linear’.
- Returns:
da_out – Merged dataarray
- Return type:
xr.DataArray