twocan.get_aligned_coordinates
- twocan.get_aligned_coordinates(moving_element: DataArray | DataTree | GeoDataFrame | DataFrame, reference_element: DataArray | DataTree | GeoDataFrame | DataFrame, transformation: BaseTransformation, reference_coordinate_system: str = 'global', moving_coordinate_system: str = 'global', new_coordinate_system: str = 'aligned', write_to_sdata: SpatialData = None) None[source]
Apply a transformation to align two spatial elements in a new coordinate system.
This function applies a spatial transformation to align a moving element with a reference element, creating a new coordinate system that contains both elements in aligned space. The transformation is applied on top of any existing transformations.
- Parameters:
moving_element (sd.models.SpatialElement) – The spatial element to be transformed (e.g., image, points, shapes).
reference_element (sd.models.SpatialElement) – The reference element that defines the target space.
transformation (BaseTransformation) – The transformation to apply to the moving element.
reference_coordinate_system (str, default="global") – Name of the coordinate system for the reference element.
moving_coordinate_system (str, default="global") – Name of the coordinate system for the moving element.
new_coordinate_system (str, default='aligned') – Name of the new coordinate system after alignment.
write_to_sdata (sd.SpatialData, optional) – If provided, write the transformation to this SpatialData object.
- Raises:
AssertionError – If the existing transformations are not BaseTransformation instances.