vyperdatum.utils.crs_utils ========================== .. py:module:: vyperdatum.utils.crs_utils Attributes ---------- .. autoapisummary:: vyperdatum.utils.crs_utils.logger Functions --------- .. autoapisummary:: vyperdatum.utils.crs_utils.crs_components vyperdatum.utils.crs_utils.auth_code vyperdatum.utils.crs_utils.vertical_shift vyperdatum.utils.crs_utils.crs_epoch vyperdatum.utils.crs_utils.add_epoch_option vyperdatum.utils.crs_utils.validate_transform_steps vyperdatum.utils.crs_utils.commandline vyperdatum.utils.crs_utils.validate_transform_steps_dict vyperdatum.utils.crs_utils.multiple_geodetic_crs vyperdatum.utils.crs_utils.multiple_projections vyperdatum.utils.crs_utils.pipeline_string vyperdatum.utils.crs_utils.vertical_axis_direction vyperdatum.utils.crs_utils.flip_vertical_vaxis vyperdatum.utils.crs_utils.get_meter_vcrs vyperdatum.utils.crs_utils.get_utm_zone_from_wkt Module Contents --------------- .. py:data:: logger .. py:function:: crs_components(crs: pyproj.CRS, raise_no_auth: bool = True) -> Tuple[str, Optional[str]] 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 :rtype: Tuple[str, Optional[str]] .. py:function:: auth_code(crs: pyproj.CRS, raise_no_auth: bool = True) -> Optional[str] 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 :rtype: str .. py:function:: 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. :param crs_from: Projection of input data. :type crs_from: pyproj.crs.CRS :param crs_to: Projection of output data. :type crs_to: pyproj.crs.CRS :raises TypeError:: If either one of `crs_from` or `crs_to` is not of type pyproj.CRS. :rtype: bool .. py:function:: crs_epoch(crs: pyproj.CRS) -> Optional[str] Return the input CRS reference epoch, if the input CRS is Dynamic. otherwise return `None`. :param crs: pyproj CRS instance. :type crs: pyproj.crs.CRS :raises TypeError:: If `crs` is not of type pyproj.CRS. .. py:function:: 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. :param s_crs: Source CRS object used in gdal Warp. :type s_crs: pyproj.crs.CRS :param t_crs: Target CRS object used in gdal Warp. :type t_crs: pyproj.crs.CRS :param warp_kwargs: Optional GDAL warp options. :type warp_kwargs: dict :raises TypeError:: If either one of `crs_from` or `crs_to` is not of type pyproj.CRS. :returns: GDAL warp options. :rtype: dict .. py:function:: validate_transform_steps(steps: Optional[list[str]]) -> bool Check if all transformation steps can be successfully instantiated by PROJ. :param steps: List of strings in form of `authority:code` representing the CRSs involved in a transformation pipeline. :type steps: Optional[list[str]] :raises NotImplementedError:: When no transformer is identified. :returns: `False` if either one of the transformation steps fail, otherwise return `True`. :rtype: bool .. py:function:: commandline(command: str, args: Optional[list[str]] = None) -> tuple[Optional[dict], Optional[str]] Spawn a new process to run a commandline utility and capture its output. :param command: The name of command (utility) to run. Example: `projinfo` :type command: str :param args: Optional arguments. :type args: Optional[list[str]] :returns: **stdout** -- standard output and error. :rtype: Optional[dict], std_err: Optional[str] .. py:function:: validate_transform_steps_dict(steps: Optional[list[dict]]) -> bool Check if all transformation steps can be successfully instantiated by PROJ. :param steps: List of dict objects containing crs_from/to in form of `authority:code` representing the CRSs involved in a transformation pipeline. :type steps: Optional[list[dict]] :raises NotImplementedError:: When no transformer is identified. :returns: `False` if either one of the transformation steps fail, otherwise return `True`. :rtype: bool .. py:function:: multiple_geodetic_crs(steps: Optional[list[dict]]) -> bool Check if there are more than one geodetic crs in the pipeline. :param steps: List of dict objects containing crs_from/to in form of `authority:code` representing the CRSs involved in a transformation pipeline. :type steps: Optional[list[dict]] :returns: `False` if all horizontal CRSs in the pipeline share the same geodetic CRS, otherwise return `True`. :rtype: bool .. py:function:: multiple_projections(steps: Optional[list[dict]]) -> bool Check if there are more than one projection types in the pipeline. :param steps: List of dict objects containing crs_from/to in form of `authority:code` representing the CRSs involved in a transformation pipeline. :type steps: Optional[list[dict]] :returns: `False` if all projected CRSs use the same projection, otherwise return `True`. :rtype: bool .. py:function:: pipeline_string(crs_from: str, crs_to, input_metadata=None) -> Optional[str] Extract PROJ pipeline string from the output of projinfo utility. :param crs_from: Source CRS in auth:code format. :type crs_from: str :param crs_to: Target CRS in auth:code format. :type crs_to: str :param input_metadata: Input raster metadata object. :type input_metadata: dict :rtype: Optional[str] .. py:function:: vertical_axis_direction(crs_auth_code) -> str .. py:function:: 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. .. py:function:: get_meter_vcrs(auth_code) .. py:function:: get_utm_zone_from_wkt(wkt_string: str) -> Optional[int] Detects if the horizontal component of a CRS (including compound) is UTM and returns the zone number.