:py:mod:`cars.applications.rasterization.rasterization_tools` ============================================================= .. py:module:: cars.applications.rasterization.rasterization_tools .. autoapi-nested-parse:: This module is responsible for the rasterization step: - it contains all functions related to 3D representation on a 2D raster grid TODO: refactor in several files and remove too-many-lines Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: cars.applications.rasterization.rasterization_tools.compute_xy_starts_and_sizes cars.applications.rasterization.rasterization_tools.simple_rasterization_dataset_wrapper cars.applications.rasterization.rasterization_tools.compute_values_1d cars.applications.rasterization.rasterization_tools.substring_in_list cars.applications.rasterization.rasterization_tools.phased_dsm cars.applications.rasterization.rasterization_tools.find_indexes_in_point_cloud cars.applications.rasterization.rasterization_tools.compute_vector_raster_and_stats cars.applications.rasterization.rasterization_tools.create_raster_dataset cars.applications.rasterization.rasterization_tools.rasterize cars.applications.rasterization.rasterization_tools.classify_performance_map cars.applications.rasterization.rasterization_tools.update_weights cars.applications.rasterization.rasterization_tools.update_data .. py:function:: compute_xy_starts_and_sizes(resolution: float, cloud: pandas.DataFrame) -> Tuple[float, float, int, int] Compute xstart, ystart, xsize and ysize of the rasterization grid from a set of points :param resolution: Resolution of rasterized cells, expressed in cloud CRS units :param cloud: set of points as returned by the create_combined_cloud function :return: a tuple (xstart, ystart, xsize, ysize) .. py:function:: simple_rasterization_dataset_wrapper(cloud: pandas.DataFrame, resolution: float, epsg: int, xstart: float = None, ystart: float = None, xsize: int = None, ysize: int = None, sigma: float = None, radius: int = 1, dsm_no_data: int = np.nan, color_no_data: int = np.nan, msk_no_data: int = 255, list_computed_layers: List[str] = None, source_pc_names: List[str] = None, performance_map_classes: List[float] = None) -> xarray.Dataset Wrapper of simple_rasterization that has xarray.Dataset as inputs and outputs. :param cloud: cloud to rasterize :param resolution: Resolution of rasterized cells, expressed in cloud CRS units or None :param epsg: epsg code for the CRS of the final raster :param color_list: Additional list of images with bands to rasterize (same size as cloud_list), or None :param xstart: xstart of the rasterization grid (if None, will be estimated by the function) :param ystart: ystart of the rasterization grid (if None, will be estimated by the function) :param xsize: xsize of the rasterization grid (if None, will be estimated by the function) :param ysize: ysize of the rasterization grid (if None, will be estimated by the function) :param sigma: sigma for gaussian interpolation. (If None, set to resolution) :param radius: Radius for hole filling. :param dsm_no_data: no data value to use in the final raster :param color_no_data: no data value to use in the final colored raster :param msk_no_data: no data value to use in the final mask image :param list_computed_layers: list of computed output data :param source_pc_names: list of names of point cloud before merging : name of sensors pair or name of point cloud file :param performance_map_classes: list for step defining border of class :type performance_map_classes: list or None :return: Rasterized cloud .. py:function:: compute_values_1d(x_start: float, y_start: float, x_size: int, y_size: int, resolution: float) -> Tuple[numpy.ndarray, numpy.ndarray] Compute the x and y values as 1d arrays :param x_start: x start of the rasterization grid :param y_start: y start of the rasterization grid :param x_size: x size of the rasterization grid :param y_size: y size of the rasterization grid :param resolution: Resolution of rasterized cells, in cloud CRS units or None. :return: a tuple composed of the x and y 1d arrays .. py:function:: substring_in_list(src_list, substring) Check if the list contains substring .. py:function:: phased_dsm(start: float, phase: float, resolution: float) Phased the dsm :param start: start of the roi :param phase: the point for phasing :param resolution: resolution of the dsm .. py:function:: find_indexes_in_point_cloud(cloud: pandas.DataFrame, tag: str, list_computed_layers: List[str] = None) -> List[str] Find all indexes in point cloud that contains the key tag if it needs to be computed :param cloud: Combined cloud :param tag: substring of desired columns in cloud :param list_computed_layers: list of computed output data .. py:function:: compute_vector_raster_and_stats(cloud: pandas.DataFrame, x_start: float, y_start: float, x_size: int, y_size: int, resolution: float, sigma: float, radius: int, list_computed_layers: List[str] = None) -> Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, numpy.ndarray, List[str], Union[None, numpy.ndarray, list, dict]] Compute vectorized raster and its statistics. :param cloud: Combined cloud as returned by the create_combined_cloud function :param x_start: x start of the rasterization grid :param y_start: y start of the rasterization grid :param x_size: x size of the rasterization grid :param y_size: y size of the rasterization grid :param resolution: Resolution of rasterized cells, expressed in cloud CRS units or None. :param sigma: Sigma for gaussian interpolation. If None, set to resolution :param radius: Radius for hole filling. :param list_computed_layers: list of computed output data :return: a tuple with rasterization results and statistics. .. py:function:: create_raster_dataset(raster: numpy.ndarray, weights_sum: numpy.ndarray, x_start: float, y_start: float, x_size: int, y_size: int, resolution: float, hgt_no_data: int, color_no_data: int, msk_no_data: int, epsg: int, mean: numpy.ndarray, stdev: numpy.ndarray, n_pts: numpy.ndarray, n_in_cell: numpy.ndarray, msk: numpy.ndarray = None, band_im: List[str] = None, classif: numpy.ndarray = None, band_classif: List[str] = None, confidences: numpy.ndarray = None, layers_inf_sup: numpy.ndarray = None, layers_inf_sup_stat_index: List[int] = None, layer_inf_sup_indexes: List[str] = None, source_pc: numpy.ndarray = None, source_pc_names: List[str] = None, filling: numpy.ndarray = None, band_filling: List[str] = None, performance_map: numpy.ndarray = None, performance_map_classified: numpy.ndarray = None, performance_map_classified_index: list = None, band_performance_map: List[str] = None) -> xarray.Dataset Create final raster xarray dataset :param raster: height and colors :param x_start: x start of the rasterization grid :param y_start: y start of the rasterization grid :param x_size: x size of the rasterization grid :param y_size: y size of the rasterization grid :param resolution: Resolution of rasterized cells, expressed in cloud CRS units or None. :param hgt_no_data: no data value to use for height :param color_no_data: no data value to use for color :param msk_no_data: no data value to use for mask and classif :param epsg: epsg code for the CRS of the final raster :param mean: mean of height and colors :param stdev: standard deviation of height and colors :param n_pts: number of points that are stricty in a cell :param n_in_cell: number of points which contribute to a cell :param msk: raster msk :param classif: raster classif :param confidences: raster containing the confidences :param layers_inf_sup: raster containing intervals inf and sup :param layers_inf_sup_stat_index: list containing index of intervals in mean and stdev rasters :param layer_inf_sup_indexes: list of band names :param source_pc: binary raster with source point cloud information :param source_pc_names: list of names of point cloud before merging : name of sensors pair or name of point cloud file :param performance_map: raster containing the raw performance map :param performance_map_classified: raster containing the classified performance map :param performance_map_classified_index: indexes of performance_map_classified :param band_performance_map: list of band names : max 2 bands: risk / interval :return: the raster xarray dataset .. py:function:: rasterize(cloud: pandas.DataFrame, resolution: float, epsg: int, x_start: float, y_start: float, x_size: int, y_size: int, sigma: float = None, radius: int = 1, hgt_no_data: int = -32768, color_no_data: int = 0, msk_no_data: int = 255, list_computed_layers: List[str] = None, source_pc_names: List[str] = None, performance_map_classes: List[float] = None) -> Union[xarray.Dataset, None] Rasterize a point cloud with its color bands to a Dataset that also contains quality statistics. :param cloud: Combined cloud as returned by the create_combined_cloud function :param resolution: Resolution of rasterized cells, expressed in cloud CRS units or None. :param epsg: epsg code for the CRS of the final raster :param x_start: x start of the rasterization grid :param y_start: y start of the rasterization grid :param x_size: x size of the rasterization grid :param y_size: y size of the rasterization grid :param sigma: sigma for gaussian interpolation. If None, set to resolution :param radius: Radius for hole filling. :param hgt_no_data: no data value to use for height :param color_no_data: no data value to use for color :param msk_no_data: no data value to use in the final mask image :param list_computed_layers: list of computed output data :param source_pc_names: list of source pc names :param performance_map_classes: list for step defining border of class :type performance_map_classes: list or None :return: Rasterized cloud color and statistics. .. py:function:: classify_performance_map(performance_map_raw, performance_map_classes, msk_no_data) Classify performance map with given classes .. py:function:: update_weights(old_weights, weights) Update weights :param weights: current weights :param old_weights: old weights :return: updated weights .. py:function:: update_data(old_data, current_data, weights, old_weights, nodata, method='basic') Update current data with old data and weigths :param old_data: old data :param current_data: current data :param weights: current weights :param old_weights: old weights :param nodata: nodata associated to tag :return: updated current data