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

Mosaic Fails with nan nodata #322

Open
mmann1123 opened this issue Jul 15, 2024 · 1 comment · May be fixed by #323
Open

Mosaic Fails with nan nodata #322

mmann1123 opened this issue Jul 15, 2024 · 1 comment · May be fixed by #323
Assignees
Labels
bug Something isn't working

Comments

@mmann1123
Copy link
Collaborator

mmann1123 commented Jul 15, 2024

Looks like nan values interfers with mosaicing images. Although I might be missing something.

# %%
import geowombat as gw
import rasterio
from geowombat.data import l8_224077_20200518_B2, l8_224078_20200518_B2
import matplotlib.pyplot as plt

fig, ax = plt.subplots(dpi=200)

with gw.open(
    [l8_224077_20200518_B2, l8_224078_20200518_B2],
    mosaic=True,
    bounds_by="union",
) as src:
    print(src)
src.where(src != 0).gw.imshow(robust=True, ax=ax)


# %%
fig, ax = plt.subplots(dpi=200)

with gw.open([l8_224077_20200518_B2], mosaic=True) as src:
    attrs = src.attrs
    src = src.where(src > 0)
    print(src)
    src.attrs = attrs
    src.gw.save(
        "l8_224077_20200518_B2.tif",
    )

src.gw.imshow(robust=True, ax=ax)
# %%
fig, ax = plt.subplots(dpi=200)

with gw.open(
    [l8_224078_20200518_B2],
    mosaic=True,
) as src:
    attrs = src.attrs
    src = src.where(src > 0)
    print(src)
    src.attrs = attrs
    src.gw.save(
        "l8_224078_20200518_B2.tif",
    )
src.gw.imshow(robust=True, ax=ax)


# %%
fig, ax = plt.subplots(dpi=200)
import numpy as np
with gw.open(
    ["l8_224077_20200518_B2.tif", "l8_224078_20200518_B2.tif"],
    mosaic=True,
    bounds_by="union",
    nodata=np.nan,
) as src:
    print(src)
src.gw.imshow(robust=True, ax=ax)

# %%

Screenshot from 2024-07-15 16-11-20

@mmann1123 mmann1123 added the bug Something isn't working label Jul 15, 2024
@mmann1123
Copy link
Collaborator Author

Nearly fixed in branch fix_mosaic_nan @jgrss

@mmann1123 mmann1123 linked a pull request Jul 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants