geost.accessor.GeostFrame.slice_depth_interval#
- GeostFrame.slice_depth_interval(upper_boundary: float | int | DataArray | str | Path = None, lower_boundary: float | int | DataArray | str | Path = None, relative_to_vertical_reference: bool = False, update_layer_boundaries: bool = True, drop_missing: bool = True) DataFrame[source]#
Slice data based on given upper and lower boundaries. This returns a new object containing only the sliced data. You may use fixed boundaries or grids for spatially varying boundaries.
Note on using grids as upper and/or lower boundaries: if you notice unexpected results do check the following: - Your data and your boundary grid(s) are in the same coordinate reference system - You have set relative_to_vertical_reference correctly according to the nature
of your grid. If your grid is relative to a vertical reference plane (e.g. “NAP”), set this parameter to True. If your grid is relative to depth below the surface, set this parameter to False.
- Parameters:
upper_boundary (float | int | xr.DataArray | str | Path, optional) – Every layer that starts above this is removed. If you are using an xarray DataArray (directly or through a file path), please set relative_to_vertical_reference according to the nature of your grid. The default is None.
lower_boundary (float | int | xr.DataArray | str | Path, optional) – Every layer that starts below this is removed. If you are using an xarray DataArray (directly or through a file path), please set relative_to_vertical_reference according to the nature of your grid. The default is None.
relative_to_vertical_reference (bool, optional) – If True, the slicing is done with respect to any kind of vertical reference plane (e.g. “NAP”, “TAW”). If False, the slice is done with respect to depth below the surface. The default is False.
update_layer_boundaries (bool, optional) – Only used when the data is layered, i.e. the data contains tops and bottoms for individual layers. If True, the layer boundaries in the sliced data are updated according to the upper and lower boundaries used with the slice. If False, the original layer boundaries are kept in the sliced object. The default is False.
drop_missing (bool, optional) – If True, any data outside the horizontal bounds of the grid or any surveys that fall in cells with missing data are removed as well. This only applies when either or both of the upper and lower boundaries are given as xarray DataArrays. The default is True.
- Returns:
New DataFrame or GeoDataFrame containing only the data within the specified depth boundaries.
- Return type:
pd.DataFrame
Examples
Usage depends on whether the slicing is done with respect to depth below the surface or to a vertical reference plane.
For example, select layers in data that are between 2 and 3 meters below the surface:
>>> sliced = data.gst.slice_depth_interval(2, 3)
By default, the method updates the layer boundaries in sliced object according to the upper and lower boundaries. To suppress this behaviour use:
>>> sliced = data.gst.slice_depth_interval(2, 3, update_layer_boundaries=False)
Slicing can also be done with respect to a vertical reference plane like “NAP”. For example, to select layers in boreholes that are between -3 and -5 m NAP, use:
>>> sliced = data.gst.slice_depth_interval(-3, -5, relative_to_vertical_reference=True)
You can also slice data based on spatially varying upper and lower boundaries by giving an xarray DataArray or file path to a raster file that serves as the upper and/or lower boundary. For example, if you have a grid representing the Holocene- Pleistocene boundary height in NAP and you want to select only data in the Holocene depth interval but below -2 m NAP you would use:
>>> sliced = data.gst.slice_depth_interval( ... upper_boundary=-2, ... lower_boundary="holocene_pleistocene_boundary.geotiff", ... relative_to_vertical_reference=True, ... update_layer_boundaries=True, ... )