vyperdatum.drivers.vrbag ======================== .. py:module:: vyperdatum.drivers.vrbag Attributes ---------- .. autoapisummary:: vyperdatum.drivers.vrbag.logger Functions --------- .. autoapisummary:: vyperdatum.drivers.vrbag.is_vr vyperdatum.drivers.vrbag.index_to_xy vyperdatum.drivers.vrbag.base_grid_point_transform vyperdatum.drivers.vrbag.update_vr_elevation vyperdatum.drivers.vrbag.get_subgrid_points vyperdatum.drivers.vrbag.single_subgrid_point_transform vyperdatum.drivers.vrbag.subgrid_point_transform vyperdatum.drivers.vrbag.single_subgrid_rsater_transform vyperdatum.drivers.vrbag.subgrid_raster_transform vyperdatum.drivers.vrbag.corner_points vyperdatum.drivers.vrbag.change_corner_points_and_wkt vyperdatum.drivers.vrbag.update_vr_refinements vyperdatum.drivers.vrbag.transform vyperdatum.drivers.vrbag.wkt Module Contents --------------- .. py:data:: logger .. py:function:: is_vr(fname: str) -> bool Return True if fname points to a variable resolution BAG file. :param fname: Absolute path to the bag file. :type fname: str :rtype: bool .. py:function:: index_to_xy(i: int, j: int, geot: tuple, x_offset, y_offset) Take indices of a cell from the base grid and return x, y. :param i: Cells's first index. :type i: int :param j: Cells's second index. :type j: int :param geot: Gdal GeoTransform tuple object. :type geot: tuple :returns: easting, northing :rtype: float, float .. py:function:: base_grid_point_transform(fname: str, tf, nodata_value) -> numpy.ndarray Transform the low-resolution grid and return the transformed values. :param fname: Absolute path to the vrbag file. :type fname: str :param tf: Instance of the transformer class. :type tf: vyperdatum.transformer.Transformer :param nodata_value: No_Data_Value used in the vrbag elevation layer. :type nodata_value: float :returns: The transformed vrbag elevation layer. :rtype: np.ndarray .. py:function:: update_vr_elevation(fname: str, arr: numpy.ndarray) -> None Update the `elevation` layer in the vrbag file with the `arr` values. :param fname: Absolute path to the vrbag file. :type fname: str :param arr: numpy array representing the elevation values to be updated. :type arr: np.ndarray :rtype: None .. py:function:: get_subgrid_points(fname: str, i: int, j: int) -> tuple[list[int], list[float], list[float], list[float]] Return the starting index and coordinates of the points of subgrid i, j. :param fname: Absolute path to the vrbag file. :type fname: str :param i: First index of the subgrid. :type i: int :param j: Second index of the subgrid. :type j: int :returns: Starting index of subgrid. x, y, z coordinates of the subgrid points. :rtype: list[int], list[float], list[float], list[float] .. py:function:: single_subgrid_point_transform(fname: str, i: int, j: int, tf, nodata_value) -> tuple[Optional[int], Optional[numpy.ndarray]] Apply point transformation of subgrid points. :param fname: Absolute path to the vrbag file. :type fname: str :param i: The first index of the subgrid. :type i: int :param j: The second index of the subgrid. :type j: int :param tf: Instance of the transformer class. :type tf: vyperdatum.transformer.Transformer :param nodata_value: No_Data_Value used for the generated GeoTiff. :type nodata_value: float :returns: The starting index of the subgrid in the varres_refinements layer. The transformed subgrid depth values in form of a 1-d array. :rtype: tuple[Optional[int], np.ndarray] .. py:function:: subgrid_point_transform(fname: str, tf) -> tuple[list[int], list[float]] Identify the subgrids within the vrbag and return the starting index and the depth values within each subgrid. :param fname: Absolute path to the vrbag file. :type fname: str :param tf: Instance of the transformer class. :type tf: vyperdatum.transformer.Transformer :returns: Starting index of each subgrid. Transformed subgrid depth values. :rtype: list[int], list[float] .. py:function:: single_subgrid_rsater_transform(fname: str, rasters_dir: str, i: int, j: int, tf, nodata_value) -> tuple[Optional[int], Optional[numpy.ndarray]] Extract a subgrid from from the vrbag file, convert to GeoTiff, and apply transformation. :param fname: Absolute path to the vrbag file. :type fname: str :param rasters_dir: Absolute path to the directory where the output TIFF files will be stored. :type rasters_dir: str :param i: First index of the subgrid. :type i: int :param j: Second index of the subgrid. :type j: int :param tf: Instance of the transformer class. :type tf: vyperdatum.transformer.Transformer :param nodata_value: No_Data_Value used for the generated GeoTiff. :type nodata_value: float :returns: * *The starting index of the subgrid in the varres_refinements layer.* * *The transformed subgrid in form of a 1-d array.* .. py:function:: subgrid_raster_transform(fname: str, rasters_dir: str, tf) -> tuple[list[int], list[float]] Identify the subgrids within the vrbag and return the starting index and the depth values within each subgrid. :param fname: Absolute path to the vrbag file. :type fname: str :param rasters_dir: Absolute path to the directory where the output TIFF files will be stored. :type rasters_dir: str :param tf: Instance of the transformer class. :type tf: vyperdatum.transformer.Transformer :returns: Starting index of each subgrid. Transformed subgrid depth values. :rtype: list[int], list[float] .. py:function:: corner_points(fname: str) -> tuple[float, float, float, float] Return the corner points indicated in the xml metadata. :param fname: Absolute path to the vrbag file. :type fname: str :returns: corner points: x1, y1, x2, y2 :rtype: str .. py:function:: change_corner_points_and_wkt(fname: str, new_points: str, wkt_h: str, wkt_v: str) -> None Update the xml metadata's corner points, horizontal, and vertical WKTs with new values. :param fname: Absolute path to the vrbag file. :type fname: str :param new_points: The new corners points in string format x1,y1 x2,y2. Will be ignored when None. :type new_points: str :param wkt_h: WKT string for the horizontal component of the CRS. Will be ignored when None. :type wkt_h: str :param wkt_v: WKT string for the vertical component of the CRS. Will be ignored when None. :type wkt_v: str :rtype: None .. py:function:: update_vr_refinements(fname: str, index: list[int], arr: list[numpy.ndarray], tf) -> None Update the `varres_refinements` layer in the vrbag file with the `arr` values starting form `index` location in the `varres_refinements`. :param fname: Absolute path to the vrbag file. :type fname: str :param index: A list of starting index where the refinements get updated. :type index: list[int] :param arr: List of numpy array representing the refinements values to be updated. :type arr: list[np.ndarray] :param tf: Instance of the transformer class. :type tf: vyperdatum.transformer.Transformer :rtype: None .. py:function:: transform(fname: str, tf, vdatum_check: bool = True, point_transformation: bool = True, **kwargs) -> bool Transform vrbag according to the `tf` Transformer object. When `point_transformation` is True, point transformation is applied, otherwise vrbag is split into rasters and raster transformation is applied. When raster transformation is chosen, a new keyword argument `rasters_dir` must be passed that specifies where the subgrid rasters are stored. :param fname: Absolute path to the vrbag file. :type fname: str :param index: A list of starting index where the refinements get updated. :type index: list[int] :param arr: List of numpy array representing the refinements values to be updated. :type arr: list[np.ndarray] :param tf: Instance of the transformer class. :type tf: vyperdatum.transformer.Transformer :param vdatum_check: If True, a random sample of the transformed data are compared with transformation outcomes produced by Vdatum REST API. :type vdatum_check: bool, default=True :param rasters_dir: Absolute path to the directory where the output TIFF files will be stored. When raster transformation is chosen, this parameter must be passed which specifies where the subgrid rasters are stored. It can point to a local dir (e.g. `rasters_dir = "./sub_grids/"`) or GDAL virtual file system (e.g. `rasters_dir = "/vsimem/sub_grids/"`). :type rasters_dir: str :raises TypeError: If the passed BAG file is not a valid variable resolution bag file. :raises KeyError: When raster transformation is chosen (`point_transformation = False`), and `rasters_dir` parameter is not passed to the function. :returns: True if successful, otherwise False. :rtype: bool .. py:function:: wkt(fname: str) -> str Return wkt retrieved by GDAL.