vyperdatum.drivers.vrbag

Attributes

logger

Functions

is_vr(→ bool)

Return True if fname points to a variable resolution BAG file.

index_to_xy(i, j, geot, x_offset, y_offset)

Take indices of a cell from the base grid and return x, y.

base_grid_point_transform(→ numpy.ndarray)

Transform the low-resolution grid and return the transformed values.

update_vr_elevation(→ None)

Update the elevation layer in the vrbag file with the arr values.

get_subgrid_points(→ tuple[list[int], list[float], ...)

Return the starting index and coordinates of the points of subgrid i, j.

single_subgrid_point_transform(→ tuple[Optional[int], ...)

Apply point transformation of subgrid points.

subgrid_point_transform(→ tuple[list[int], list[float]])

Identify the subgrids within the vrbag and return the starting

single_subgrid_rsater_transform(→ tuple[Optional[int], ...)

Extract a subgrid from from the vrbag file, convert to GeoTiff, and apply transformation.

subgrid_raster_transform(→ tuple[list[int], list[float]])

Identify the subgrids within the vrbag and return the starting

corner_points(→ tuple[float, float, float, float])

Return the corner points indicated in the xml metadata.

change_corner_points_and_wkt(→ None)

Update the xml metadata's corner points, horizontal, and vertical WKTs with new values.

update_vr_refinements(→ None)

Update the varres_refinements layer in the vrbag file with the

transform(→ bool)

Transform vrbag according to the tf Transformer object.

wkt(→ str)

Return wkt retrieved by GDAL.

Module Contents

vyperdatum.drivers.vrbag.logger
vyperdatum.drivers.vrbag.is_vr(fname: str) bool

Return True if fname points to a variable resolution BAG file.

Parameters:

fname (str) – Absolute path to the bag file.

Return type:

bool

vyperdatum.drivers.vrbag.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.

Parameters:
  • i (int) – Cells’s first index.

  • j (int) – Cells’s second index.

  • geot (tuple) – Gdal GeoTransform tuple object.

Returns:

easting, northing

Return type:

float, float

vyperdatum.drivers.vrbag.base_grid_point_transform(fname: str, tf, nodata_value) numpy.ndarray

Transform the low-resolution grid and return the transformed values.

Parameters:
Returns:

The transformed vrbag elevation layer.

Return type:

np.ndarray

vyperdatum.drivers.vrbag.update_vr_elevation(fname: str, arr: numpy.ndarray) None

Update the elevation layer in the vrbag file with the arr values.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • arr (np.ndarray) – numpy array representing the elevation values to be updated.

Return type:

None

vyperdatum.drivers.vrbag.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.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • i (int) – First index of the subgrid.

  • j (int) – Second index of the subgrid.

Returns:

Starting index of subgrid. x, y, z coordinates of the subgrid points.

Return type:

list[int], list[float], list[float], list[float]

vyperdatum.drivers.vrbag.single_subgrid_point_transform(fname: str, i: int, j: int, tf, nodata_value) tuple[int | None, numpy.ndarray | None]

Apply point transformation of subgrid points.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • i (int) – The first index of the subgrid.

  • j (int) – The second index of the subgrid.

  • tf (vyperdatum.transformer.Transformer) – Instance of the transformer class.

  • nodata_value (float) – No_Data_Value used for the generated GeoTiff.

Returns:

The starting index of the subgrid in the varres_refinements layer. The transformed subgrid depth values in form of a 1-d array.

Return type:

tuple[Optional[int], np.ndarray]

vyperdatum.drivers.vrbag.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.

Parameters:
Returns:

Starting index of each subgrid. Transformed subgrid depth values.

Return type:

list[int], list[float]

vyperdatum.drivers.vrbag.single_subgrid_rsater_transform(fname: str, rasters_dir: str, i: int, j: int, tf, nodata_value) tuple[int | None, numpy.ndarray | None]

Extract a subgrid from from the vrbag file, convert to GeoTiff, and apply transformation.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • rasters_dir (str) – Absolute path to the directory where the output TIFF files will be stored.

  • i (int) – First index of the subgrid.

  • j (int) – Second index of the subgrid.

  • tf (vyperdatum.transformer.Transformer) – Instance of the transformer class.

  • nodata_value (float) – No_Data_Value used for the generated GeoTiff.

Returns:

  • The starting index of the subgrid in the varres_refinements layer.

  • The transformed subgrid in form of a 1-d array.

vyperdatum.drivers.vrbag.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.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • rasters_dir (str) – Absolute path to the directory where the output TIFF files will be stored.

  • tf (vyperdatum.transformer.Transformer) – Instance of the transformer class.

Returns:

Starting index of each subgrid. Transformed subgrid depth values.

Return type:

list[int], list[float]

vyperdatum.drivers.vrbag.corner_points(fname: str) tuple[float, float, float, float]

Return the corner points indicated in the xml metadata.

Parameters:

fname (str) – Absolute path to the vrbag file.

Returns:

corner points: x1, y1, x2, y2

Return type:

str

vyperdatum.drivers.vrbag.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.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • new_points (str) – The new corners points in string format x1,y1 x2,y2. Will be ignored when None.

  • wkt_h (str) – WKT string for the horizontal component of the CRS. Will be ignored when None.

  • wkt_v (str) – WKT string for the vertical component of the CRS. Will be ignored when None.

Return type:

None

vyperdatum.drivers.vrbag.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.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • index (list[int]) – A list of starting index where the refinements get updated.

  • arr (list[np.ndarray]) – List of numpy array representing the refinements values to be updated.

  • tf (vyperdatum.transformer.Transformer) – Instance of the transformer class.

Return type:

None

vyperdatum.drivers.vrbag.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.

Parameters:
  • fname (str) – Absolute path to the vrbag file.

  • index (list[int]) – A list of starting index where the refinements get updated.

  • arr (list[np.ndarray]) – List of numpy array representing the refinements values to be updated.

  • tf (vyperdatum.transformer.Transformer) – Instance of the transformer class.

  • vdatum_check (bool, default=True) – If True, a random sample of the transformed data are compared with transformation outcomes produced by Vdatum REST API.

  • rasters_dir (str) – 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/”).

Raises:
  • TypeError – If the passed BAG file is not a valid variable resolution bag file.

  • 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.

Return type:

bool

vyperdatum.drivers.vrbag.wkt(fname: str) str

Return wkt retrieved by GDAL.