Skip to content

joining two indexes raises a AssertionError #67

@keewis

Description

@keewis

When trying to join two partially overlapping RasterIndexes, a AssertionError is raised. The difference is exactly half the step size, so maybe there's a corner and a center transform involved?

import rasterix
import affine

transform1 = affine.Affine.from_gdal(399955.0, 10.0, 0.0, 5500025.0, 0.0, -10.0)
transform2 = affine.Affine.from_gdal(399955.0, 10.0, 0.0, 5497625.0, 0.0, -10.0)

index1 = rasterix.RasterIndex.from_transform(transform1, width=256, height=256)
index2 = rasterix.RasterIndex.from_transform(transform2, width=256, height=256)

index1.join(index2, how="inner") # AssertionError

Full traceback:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[1], line 10
      7 index1 = rasterix.RasterIndex.from_transform(transform1, width=256, height=256)
      8 index2 = rasterix.RasterIndex.from_transform(transform2, width=256, height=256)
---> 10 index1.join(index2, how="inner")

File .../.pixi/envs/dev/lib/python3.13/site-packages/rasterix/raster_index.py:757, in RasterIndex.join(self, other, how)
    754 else:
    755     raise NotImplementedError(f"{how=!r} not implemented yet for RasterIndex.")
--> 757 return self._new_with_bbox(new_bbox)

File .../.pixi/envs/dev/lib/python3.13/site-packages/rasterix/raster_index.py:733, in RasterIndex._new_with_bbox(self, bbox)
    731 # TODO: set xdim, ydim explicitly
    732 new_index = self.from_transform(new_affine, width=Nx, height=Ny)
--> 733 assert new_index.bbox == bbox
    734 return new_index

AssertionError: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions