demcompare.dataset_tools ======================== .. py:module:: demcompare.dataset_tools .. autoapi-nested-parse:: This module contains functions associated to Demcompare's DEM dataset Functions --------- .. autoapisummary:: demcompare.dataset_tools.create_dataset demcompare.dataset_tools.reproject_dataset demcompare.dataset_tools.compute_offset_adapting_factor demcompare.dataset_tools._get_geoid_offset demcompare.dataset_tools._interpolate_geoid Module Contents --------------- .. py:function:: create_dataset(data: numpy.ndarray, transform: Union[numpy.ndarray, rasterio.Affine] = None, img_crs: Union[rasterio.crs.CRS, None] = None, input_img: Union[str, None] = None, bounds: rasterio.coords.BoundingBox = None, nodata: float = None, geoid_path: Union[str, None] = None, plani_unit: astropy.units = None, zunit: str = 'm', source_rasterio: Dict[str, rasterio.DatasetReader] = None, classification_layer_masks: Union[Dict, xarray.DataArray] = None) -> xarray.Dataset Creates dataset from input array and transform, and return the corresponding xarray.DataSet. The demcompare dataset is an xarray Dataset containing: :image: 2D (row, col) image as xarray.DataArray, :georef_transform: 1D (trans_len) xarray.DataArray with the parameters: - c: x-coordinate of the upper left pixel, - a: pixel size in the x-direction in map units/pixel, - b: rotation about x-axis, - f: y-coordinate of the upper left pixel, - d: rotation about y-axis, - e: pixel size in the y-direction in map units, negative :classification_layer_masks: 3D (row, col, indicator) xarray.DataArray: It contains the maps of all classification layers, being the indicator a list with each classification_layer name. :attributes: - nodata : image nodata value. float - input_img : image input path. str or None - crs : image crs. rasterio.crs.CRS - xres : x resolution (value of transform[1]). float - yres : y resolution (value of transform[5]). float - plani_unit : georefence's planimetric unit. astropy.units - zunit : input image z unit value. astropy.units - bounds : image bounds. rasterio.coords.BoundingBox - geoid_path : geoid path. str or None - source_rasterio : rasterio's DatasetReader object or None. :param data: image data :type data: np.ndarray :param transform: rasterio georeferencing transformation matrix :type transform: np.ndarray or rasterio.Affine :param input_img: image path :type input_img: str :param bounds: dem bounds :type bounds: rasterio.coords.BoundingBox or None :param nodata: nodata value in the image :type nodata: float or None :param geoid_path: optional path to local geoid, default is EGM96 :type geoid_path: str or None :param zunit: unit :type zunit: str :param source_rasterio: rasterio dataset reader object :type source_rasterio: Dict[str,rasterio.DatasetReader] or None :param classification_layer_masks: classification layers :type classification_layer_masks: Dict, xr.DataArray or None :return: xr.DataSet containing : - image : 2D (row, col) xr.DataArray float32 - georef_transform: 1D (trans_len) xr.DataArray - classification_layer_masks : 3D (row, col, indicator) xr.DataArray :type data: xr.Dataset .. py:function:: reproject_dataset(dataset: xarray.Dataset, from_dataset: xarray.Dataset, interp: str = 'bilinear') -> xarray.Dataset Reproject dataset on the from_dataset's georeference origin and grid, and return the corresponding xarray.DataSet. If no interp is given, default "bilinear" resampling is considered. Another available resampling is "nearest". :param dataset: Dataset to reproject xr.DataSet containing : - image : 2D (row, col) xr.DataArray float32 - georef_transform: 1D (trans_len) xr.DataArray - classification_layer_masks : 3D (row, col, indicator) xr.DataArray :type dataset: xr.Dataset :param from_dataset: Dataset to get projection from xr.DataSet containing : - image : 2D (row, col) xr.DataArray float32 - georef_transform: 1D (trans_len) xr.DataArray - classification_layer_masks : 3D (row, col, indicator) xr.DataArray :type from_dataset: xr.Dataset :param interp: interpolation method :type interp: str :return: reprojected xr.DataSet containing : - image : 2D (row, col) xr.DataArray float32 - georef_transform: 1D (trans_len) xr.DataArray - classification_layer_masks : 3D (row, col, indicator) xr.DataArray :rtype: xr.Dataset .. py:function:: compute_offset_adapting_factor(sec: xarray.Dataset, ref: xarray.Dataset) -> Tuple[float, float] Compute the factor to adapt the coregistration offsets to the dem resolution The name is too generic to know the usage quickly. Is the function in dem_tools or here ? :param sec: sec :type sec: xr.Dataset :param ref: ref :type ref: xr.Dataset :return: x and y factors :rtype: Tuple[float, float] .. py:function:: _get_geoid_offset(dataset: xarray.Dataset, geoid_path: Union[str, None]) -> numpy.ndarray Computes the geoid offset of the input DEM. If no geoid_path is given, the default geoid/egm96_15.gtx if used. :param dataset: xr.DataSet containing : - image : 2D (row, col) xr.DataArray float32 - georef_transform: 1D (trans_len) xr.DataArray - classification_layer_masks : 3D (row, col, indicator) xr.DataArray :type dataset: xr.Dataset :param geoid_path: optional absolut geoid_path, if None egm96 is used :type geoid_path: str or None :return: offset as array :rtype: np.ndarray .. py:function:: _interpolate_geoid(geoid_filename: str, coords: numpy.ndarray, interpol_method: str = 'linear') -> numpy.ndarray Bilinear interpolation of the given geoid to the input coordinates. If no interpol_method is given, a "linear" interpolation is considered. If the input coordinates are outside of the geoid scope, an exception is raised. :param geoid_filename: coord geoid_filename :type geoid_filename: str :param coords: coords matrix 2xN [lon,lat] :type coords: np.ndarray :param interpol_method: interpolation type :type interpol_method: str :return: interpolated position [lon,lat,estimate geoid] :rtype: 3D np.array