pytuflow.Grid#
- class Grid(fpath)#
Bases:
MapOutput,LineStringMixin,PointMixinGeneric Grid result class. Can be used to load raster files that are supported by GDAL or rasterio. The raster data extracted from an input file is assumed to be static (i.e. no time dimension). Alternatively, it is possible to initialise the Grid class with a dictionary containing already extracted grid data in the form of an array. The dictionary should include metadata about the grid such as cell size, origin, and number of rows/columns. The data can be either static or temporal.
- Parameters:
fpath (PathLike | dict) –
The file path to the grid file to load, or a dictionary containing grid data (as a
np.ndarray) and metadata.If using a dictionary, the following keys should be present:
dx: floatdy: floatncol: intnrow: intox: float : optional, default is 0.0oy: float : optional, default is 0.0nodatavalue: float, optional, default is np.nandata: np.ndarray. Array can be 2D (static scalar, NRow,NCol), 3D (temporal scalar,NTime,NRow,NCol), 3D (static vector,NRow,NCol,2), or 4D (temporal vector,NTime,NRow,NCol,2). If data represents vector data, then thedtypekey must also be set to"vector". If data is temporal, then thetimestepskey must also be provided.data_type: str, optional data type (result type) identifiertimesteps: list[float] | int, optional. If data is temporal, this should be a list of time values.dtype: str, optional. Either"scalar"(default) or"vector".
Examples
Load a static grid from a GeoTIFF file:
>>> grid = Grid('path/to/static_grid.tif') >>> grid.dx 10.0 >>> df = grid.surface() x y value active 0 292723.75 6177421.25 NaN False 1 292726.25 6177421.25 NaN False 2 292728.75 6177421.25 NaN False 3 292731.25 6177421.25 NaN False 4 292733.75 6177421.25 NaN False ... ... ... ... ... 197536 293768.75 6178586.25 NaN False 197537 293771.25 6178586.25 NaN False 197538 293773.75 6178586.25 NaN False 197539 293776.25 6178586.25 NaN False 197540 293778.75 6178586.25 NaN False
- __init__(fpath)#
- Parameters:
fpath (Path | str | dict)
Methods
Extracts the data value for the given point locations and data types at the specified time.
Returns all the available data types (result types) for the output given the context.
Returns the maximum values for the given data types.
Returns the minimum values for the given data types.
Extracts section data for the given locations and data types.
Returns the value for every cell/vertex at the specified time.
Extracts time-series data for the given locations and data types.
Returns all the available times for the given context.
Converts the grid to a
GridMeshobject, essentially converting the grid data structure into a mesh data structure.Attributes
The grid cell size in the x-direction.
The grid cell size in the y-direction.
The number of columns in the grid.
The no data value for the grid.
The number of rows in the grid.
The x-origin of the grid.
The y-origin of the grid.
The result name
Does the result have an inherent reference time.
The reference time for the output