vyperdatum.utils.crs_utils

Attributes

logger

Functions

crs_components(→ Tuple[str, Optional[str]])

Return CRS horizontal and vertical components string representation

auth_code(→ Optional[str])

Return CRS string representation in form of code:authority

vertical_shift(→ bool)

Return True if transformation from crs_from to crs_to results

crs_epoch(→ Optional[str])

Return the input CRS reference epoch, if the input CRS is Dynamic.

add_epoch_option(s_crs, t_crs, warp_kwargs)

Add epoch info to the GDAL warp options if either source or target CRSs are dynamic.

validate_transform_steps(→ bool)

Check if all transformation steps can be successfully instantiated by PROJ.

commandline(→ tuple[Optional[dict], Optional[str]])

Spawn a new process to run a commandline utility and capture its output.

validate_transform_steps_dict(→ bool)

Check if all transformation steps can be successfully instantiated by PROJ.

multiple_geodetic_crs(→ bool)

Check if there are more than one geodetic crs in the pipeline.

multiple_projections(→ bool)

Check if there are more than one projection types in the pipeline.

pipeline_string(→ Optional[str])

Extract PROJ pipeline string from the output of projinfo utility.

vertical_axis_direction(→ str)

flip_vertical_vaxis(→ str)

Finds the flipped VCRS by explicitly swapping 'height' and 'depth'

get_meter_vcrs(auth_code)

get_utm_zone_from_wkt(→ Optional[int])

Detects if the horizontal component of a CRS (including compound)

Module Contents

vyperdatum.utils.crs_utils.logger
vyperdatum.utils.crs_utils.crs_components(crs: pyproj.CRS, raise_no_auth: bool = True) Tuple[str, str | None]

Return CRS horizontal and vertical components string representation in form of code:authority. If the input CRS is horizontal, the vertical component will be None.

Raises:

ValueError: – If either code or authority of the crs (or its sub_crs) can not be determined.

Returns:

Horizontal and vertical components of crs in form of code:authority

Return type:

Tuple[str, Optional[str]]

vyperdatum.utils.crs_utils.auth_code(crs: pyproj.CRS, raise_no_auth: bool = True) str | None

Return CRS string representation in form of code:authority

Raises:

ValueError: – If either code or authority of the crs (or its sub_crs) can not be determined.

Returns:

crs string in form of code:authority

Return type:

str

vyperdatum.utils.crs_utils.vertical_shift(crs_from: pyproj.CRS, crs_to: pyproj.CRS) bool

Return True if transformation from crs_from to crs_to results in vertical shifts.

Parameters:
Raises:

TypeError: – If either one of crs_from or crs_to is not of type pyproj.CRS.

Return type:

bool

vyperdatum.utils.crs_utils.crs_epoch(crs: pyproj.CRS) str | None

Return the input CRS reference epoch, if the input CRS is Dynamic. otherwise return None.

Parameters:

crs (pyproj.crs.CRS) – pyproj CRS instance.

Raises:

TypeError: – If crs is not of type pyproj.CRS.

vyperdatum.utils.crs_utils.add_epoch_option(s_crs: pyproj.CRS, t_crs: pyproj.CRS, warp_kwargs: dict)

Add epoch info to the GDAL warp options if either source or target CRSs are dynamic.

Parameters:
  • s_crs (pyproj.crs.CRS) – Source CRS object used in gdal Warp.

  • t_crs (pyproj.crs.CRS) – Target CRS object used in gdal Warp.

  • warp_kwargs (dict) – Optional GDAL warp options.

Raises:

TypeError: – If either one of crs_from or crs_to is not of type pyproj.CRS.

Returns:

GDAL warp options.

Return type:

dict

vyperdatum.utils.crs_utils.validate_transform_steps(steps: list[str] | None) bool

Check if all transformation steps can be successfully instantiated by PROJ.

Parameters:

steps (Optional[list[str]]) – List of strings in form of authority:code representing the CRSs involved in a transformation pipeline.

Raises:

NotImplementedError: – When no transformer is identified.

Returns:

False if either one of the transformation steps fail, otherwise return True.

Return type:

bool

vyperdatum.utils.crs_utils.commandline(command: str, args: list[str] | None = None) tuple[dict | None, str | None]

Spawn a new process to run a commandline utility and capture its output.

Parameters:
  • command (str) – The name of command (utility) to run. Example: projinfo

  • args (Optional[list[str]]) – Optional arguments.

Returns:

stdout – standard output and error.

Return type:

Optional[dict], std_err: Optional[str]

vyperdatum.utils.crs_utils.validate_transform_steps_dict(steps: list[dict] | None) bool

Check if all transformation steps can be successfully instantiated by PROJ.

Parameters:

steps (Optional[list[dict]]) – List of dict objects containing crs_from/to in form of authority:code representing the CRSs involved in a transformation pipeline.

Raises:

NotImplementedError: – When no transformer is identified.

Returns:

False if either one of the transformation steps fail, otherwise return True.

Return type:

bool

vyperdatum.utils.crs_utils.multiple_geodetic_crs(steps: list[dict] | None) bool

Check if there are more than one geodetic crs in the pipeline.

Parameters:

steps (Optional[list[dict]]) – List of dict objects containing crs_from/to in form of authority:code representing the CRSs involved in a transformation pipeline.

Returns:

False if all horizontal CRSs in the pipeline share the same geodetic CRS, otherwise return True.

Return type:

bool

vyperdatum.utils.crs_utils.multiple_projections(steps: list[dict] | None) bool

Check if there are more than one projection types in the pipeline.

Parameters:

steps (Optional[list[dict]]) – List of dict objects containing crs_from/to in form of authority:code representing the CRSs involved in a transformation pipeline.

Returns:

False if all projected CRSs use the same projection, otherwise return True.

Return type:

bool

vyperdatum.utils.crs_utils.pipeline_string(crs_from: str, crs_to, input_metadata=None) str | None

Extract PROJ pipeline string from the output of projinfo utility.

Parameters:
  • crs_from (str) – Source CRS in auth:code format.

  • crs_to (str) – Target CRS in auth:code format.

  • input_metadata (dict) – Input raster metadata object.

Return type:

Optional[str]

vyperdatum.utils.crs_utils.vertical_axis_direction(crs_auth_code) str
vyperdatum.utils.crs_utils.flip_vertical_vaxis(auth_code) str

Finds the flipped VCRS by explicitly swapping ‘height’ and ‘depth’ in the CRS name and searching the database for that exact name.

vyperdatum.utils.crs_utils.get_meter_vcrs(auth_code)
vyperdatum.utils.crs_utils.get_utm_zone_from_wkt(wkt_string: str) int | None

Detects if the horizontal component of a CRS (including compound) is UTM and returns the zone number.