geost.models.model_dataset.ModelDataset.select_points#

ModelDataset.select_points(points: str | Path | gpd.GeoDataFrame | GeometryType, crs: str | int | CRS | None = None, drop: bool = True, add_point_survey_ids: bool = False, return_collection: bool = False) → xr.Dataset | xr.DataArray | Collection#

Select model data at specified point locations. The points can be provided as a GeoDataFrame, a shapely geometry, or a path to a file that can be read into a GeoDataFrame. The points must have a valid coordinate reference system (CRS) that matches the model’s CRS, or the user can specify the CRS of the points using the crs parameter.

Parameters:
  • points (str | Path | gpd.GeoDataFrame | GeometryType) – Points to select.

  • crs (str | int | CRS | None, optional) – Coordinate reference system of the points. If None, the CRS of the points is assumed to be the same as the model. The default is None.

  • drop (bool, optional) – If True, points outside the model bounds are removed from the result. If False, points outside the model bounds result in full NaN columns. The default is True. This parameter is ignored when return_collection=True.

  • add_point_survey_ids (bool, optional) – If True, add the survey ID of the points to the result. Note, that this requires the points to have a valid survey ID column which can be accessed through the points.gst.nr property. Otherwise, a MissingSurveyIDError will be raised. The default is False.

  • return_collection (bool, optional) – If True, the result is returned as a Collection object instead of an xarray object. The default is False.

Returns:

Subset of the original Dataset or DataArray with coordinate “idx” corresponding to the selected points. If return_collection=True, a Collection object is returned instead.

Return type:

xr.Dataset | xr.DataArray | Collection

Example

Use a GeoDataFrame with points to select the model at the x,y-locations of the points:

>>> import geopandas as gpd
>>> points = gpd.GeoDataFrame(
...     geometry=gpd.points_from_xy([0.8, 2.4, 1.0], [0.8, 2.4, 0.5]), crs="EPSG:28992"
... )
>>> model.gst.select_points(points) # Select the model at the point locations

If the points are in a different CRS than the model, specify the CRS of the points:

>>> points_wgs = points.to_crs(4326) # Change the CRS of the points to WGS84
>>> model.gst.select_points(points_wgs, crs=4326) # Specify the CRS of the points

The result can also be directly be returned as a Collection object by setting the return_collection parameter to True.

>>> collection = model.gst.select_points(points, return_collection=True)