pytuflow.Grid.data_point#
- Grid.data_point(locations, data_types=(), time=0)#
Extracts the data value for the given point locations and data types at the specified time.
The
locationscan be a single point in the form of a tuple(x, y)or in the Well Known Text (WKT) format. It can also be a list of points, or a dictionary of points where the key will be used in the column name in the resulting DataFrame.The
locationsargument can also be a single GIS file path e.g. Shapefile or GPKG (but any format supported by GDAL is also supported). GPKG’s should follow the TUFLOW convention if specifying the layer name within the databasedatabase.gpkg >> layer. If the GIS layer has a field calledname,label, orIDthen this will be used as the column name in the resulting DataFrame.The returned value will be a single float if a single location and data type is provided, or a tuple if the data type is a vector result type. If multiple locations and/or data types are provided, a DataFrame will be returned with the data types as columns and the point locations as the index.
- Parameters:
locations (Point | list[Point] | dict[str, Point] | PathLike) – The location to extract the data for.
data_types (str | list[str], optional) – The data types to extract the data for. If left blank, water level will be used if it exists, otherwise the first data type found in the result will be used.
time (TimeLike, optional) – The time to extract the data for.
- Returns:
The data value(s) for the given location(s) and data type(s).
- Return type:
float | tuple[float, float] | pd.DataFrame
Examples
Get the water level data for a given point defined as
(x, y):>>> grid = ... # Assume grid is a loaded grid result instance >>> grid.data_point((293250, 6178030), 'water level', 1.5) 42.723076
Get the maximum water level and depth for multiple points defined in a shapefile. Time is passed as
-1since it is a static dataset (it could be any time value since it won’t affect the result):>>> grid.data_point('/path/to/points.shp', ['max water level', 'max depth'], -1) max water level max depth pnt1 40.501997 2.785571 pnt2 43.221862 3.450053