cars.applications.rasterization.rasterization_tools

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

compute_xy_starts_and_sizes(→ Tuple[float, float, int, ...)

Compute xstart, ystart, xsize and ysize

simple_rasterization_dataset_wrapper(→ xarray.Dataset)

Wrapper of simple_rasterization

compute_values_1d(→ Tuple[numpy.ndarray, numpy.ndarray])

Compute the x and y values as 1d arrays

substring_in_list(src_list, substring)

Check if the list contains substring

find_indexes_in_point_cloud(→ List[str])

Find all indexes in point cloud that contains the key tag

compute_vector_raster_and_stats(→ Tuple[numpy.ndarray, ...)

Compute vectorized raster and its statistics.

create_raster_dataset(→ xarray.Dataset)

Create final raster xarray dataset

rasterize(→ Union[xarray.Dataset, None])

Rasterize a point cloud with its color bands to a Dataset

update_weights(old_weights, weights)

Update weights

update_data(old_data, current_data, weights, ...[, method])

Update current data with old data and weigths

cars.applications.rasterization.rasterization_tools.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

Parameters
  • resolution – Resolution of rasterized cells, expressed in cloud CRS units

  • cloud – set of points as returned by the create_combined_cloud function

Returns

a tuple (xstart, ystart, xsize, ysize)

cars.applications.rasterization.rasterization_tools.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) xarray.Dataset

Wrapper of simple_rasterization that has xarray.Dataset as inputs and outputs.

Parameters
  • cloud – cloud to rasterize

  • resolution – Resolution of rasterized cells, expressed in cloud CRS units or None

  • epsg – epsg code for the CRS of the final raster

  • color_list – Additional list of images with bands to rasterize (same size as cloud_list), or None

  • xstart – xstart of the rasterization grid (if None, will be estimated by the function)

  • ystart – ystart of the rasterization grid (if None, will be estimated by the function)

  • xsize – xsize of the rasterization grid (if None, will be estimated by the function)

  • ysize – ysize of the rasterization grid (if None, will be estimated by the function)

  • sigma – sigma for gaussian interpolation. (If None, set to resolution)

  • radius – Radius for hole filling.

  • dsm_no_data – no data value to use in the final raster

  • color_no_data – no data value to use in the final colored raster

  • msk_no_data – no data value to use in the final mask image

  • list_computed_layers – list of computed output data

  • source_pc_names – list of names of points cloud before merging : name of sensors pair or name of point cloud file

Returns

Rasterized cloud

cars.applications.rasterization.rasterization_tools.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

Parameters
  • x_start – x start of the rasterization grid

  • y_start – y start of the rasterization grid

  • x_size – x size of the rasterization grid

  • y_size – y size of the rasterization grid

  • resolution – Resolution of rasterized cells, in cloud CRS units or None.

Returns

a tuple composed of the x and y 1d arrays

cars.applications.rasterization.rasterization_tools.substring_in_list(src_list, substring)

Check if the list contains substring

cars.applications.rasterization.rasterization_tools.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

cars.applications.rasterization.rasterization_tools.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]]

Compute vectorized raster and its statistics.

Parameters
  • cloud – Combined cloud as returned by the create_combined_cloud function

  • x_start – x start of the rasterization grid

  • y_start – y start of the rasterization grid

  • x_size – x size of the rasterization grid

  • y_size – y size of the rasterization grid

  • resolution – Resolution of rasterized cells, expressed in cloud CRS units or None.

  • sigma – Sigma for gaussian interpolation. If None, set to resolution

  • radius – Radius for hole filling.

  • list_computed_layers – list of computed output data

Returns

a tuple with rasterization results and statistics.

cars.applications.rasterization.rasterization_tools.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, interval: numpy.ndarray = None, source_pc: numpy.ndarray = None, source_pc_names: List[str] = None, filling: numpy.ndarray = None, band_filling: List[str] = None) xarray.Dataset

Create final raster xarray dataset

Parameters
  • raster – height and colors

  • x_start – x start of the rasterization grid

  • y_start – y start of the rasterization grid

  • x_size – x size of the rasterization grid

  • y_size – y size of the rasterization grid

  • resolution – Resolution of rasterized cells, expressed in cloud CRS units or None.

  • hgt_no_data – no data value to use for height

  • color_no_data – no data value to use for color

  • msk_no_data – no data value to use for mask and classif

  • epsg – epsg code for the CRS of the final raster

  • mean – mean of height and colors

  • stdev – standard deviation of height and colors

  • n_pts – number of points that are stricty in a cell

  • n_in_cell – number of points which contribute to a cell

  • msk – raster msk

  • classif – raster classif

  • confidence_from_ambiguity – raster msk

  • source_pc – binary raster with source point cloud information

  • source_pc_names – list of names of points cloud before merging : name of sensors pair or name of point cloud file

Returns

the raster xarray dataset

cars.applications.rasterization.rasterization_tools.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) Union[xarray.Dataset, None]

Rasterize a point cloud with its color bands to a Dataset that also contains quality statistics.

Parameters
  • cloud – Combined cloud as returned by the create_combined_cloud function

  • resolution – Resolution of rasterized cells, expressed in cloud CRS units or None.

  • epsg – epsg code for the CRS of the final raster

  • x_start – x start of the rasterization grid

  • y_start – y start of the rasterization grid

  • x_size – x size of the rasterization grid

  • y_size – y size of the rasterization grid

  • sigma – sigma for gaussian interpolation. If None, set to resolution

  • radius – Radius for hole filling.

  • hgt_no_data – no data value to use for height

  • color_no_data – no data value to use for color

  • msk_no_data – no data value to use in the final mask image

  • list_computed_layers – list of computed output data

Returns

Rasterized cloud color and statistics.

cars.applications.rasterization.rasterization_tools.update_weights(old_weights, weights)

Update weights

Parameters
  • weights – current weights

  • old_weights – old weights

Returns

updated weights

cars.applications.rasterization.rasterization_tools.update_data(old_data, current_data, weights, old_weights, nodata, method='basic')

Update current data with old data and weigths

Parameters
  • old_data – old data

  • current_data – current data

  • weights – current weights

  • old_weights – old weights

  • nodata – nodata associated to tag

Returns

updated current data