semantique.processor.arrays.Array.align_with

semantique.processor.arrays.Array.align_with#

Array.align_with(other)[source]#

Align the array to the shape of another array.

An input array is alinged to another array if the pixel at position i in the input array has the same coordinates as the pixel at position i in the other array. Aligning can be done in several ways:

  • Consider the case where the input array has exactly the same dimensions and coordinates as the other array, but the order of them is different. In that case, the input array is simply re-ordered to match the other array.

  • Consider the case where the input array has the same dimensions as the other array, but not all coordinates match. In that case, the coordinates that are in the input array but not in the other array are removed from the input array, and at the same time the coordinates that are in the other array but not in the input array are added to the input array, with nodata values assigned.

  • Consider the case where all dimensions of the input array are also present in the other array, but not all dimensions of the other array are present in the input array. In that case, the pixels of the input array are duplicated along those dimensions that are missing.

Alignment may also be a combination of more than one of these ways.

Parameters:

other (xarray.DataArray) – Array to which the input array should be aligned.

Returns:

xarray.DataArray – The aligned input array.

Raises:

exceptions.AlignmentError – If the input array cannot be aligned to the other array, for example when the two arrays have no dimensions in common at all, or when the input array has dimensions that are not present in the other array.