Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change in reproject behavior introduced in 1.4b2 #3222

Open
sgillies opened this issue Oct 28, 2024 Discussed in #3215 · 1 comment · Fixed by #3223
Open

Change in reproject behavior introduced in 1.4b2 #3222

sgillies opened this issue Oct 28, 2024 Discussed in #3215 · 1 comment · Fixed by #3223
Assignees
Labels

Comments

@sgillies
Copy link
Member

Discussed in #3215

Originally posted by bmcandr October 17, 2024
I'm investigating an error in my application that appeared after upgrading from 1.3.10 to 1.4.1. A call to reproject with a single band, 2D masked array as source now returns a 3D masked array when it previously returned a 2D array.
I suspect this change in behavior was introduced with this change, but it is unclear to me whether this is an intentional result or an unintended regression.

I can demonstrate this change using one of the tests added in the PR (test_reproject_masked_masked_output) by adding a simple assertion check on the number of dimensions of inp and out:

def test_reproject_masked_masked_output(test3d, count_nonzero, path_rgb_byte_tif):
    with rasterio.open(path_rgb_byte_tif) as src:
        if test3d:
            inp = src.read(masked=True)
        else:
            inp = src.read(1, masked=True)
    out = np.ma.masked_array(np.empty(inp.shape, dtype=np.uint8))
    out, _ = reproject(
        inp,
        out,
        src_transform=src.transform,
        src_crs=src.crs,
        dst_transform=DST_TRANSFORM,
        dst_crs="EPSG:3857",
    )
    # new assert
    assert out.ndim == inp.ndim
    assert np.count_nonzero(out[out != np.ma.masked]) == count_nonzero

When test3d = False, the test fails with:

>       assert out.ndim == inp.ndim
E       assert 3 == 2

For comparison, this assertion check passes when running this test on 1.3.10.


Is this new behavior intended?

@sgillies
Copy link
Member Author

@bmcandr I can confirm this and will have a fix in 1.4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant