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

Transfer color interpolation #114

Closed
wants to merge 4 commits into from

Conversation

pierotofy
Copy link
Contributor

Should fix #113

@pierotofy
Copy link
Contributor Author

p.s. not sure why circleci is failing, but tests run fine on the dev machine:

root@af356896952a:/webodm/tmp/rio-cogeo# pytest tests
========================== test session starts ==========================
platform linux -- Python 3.6.9, pytest-5.3.2, py-1.8.0, pluggy-0.13.1
rootdir: /webodm/tmp/rio-cogeo
plugins: cov-2.8.1, celery-4.1.0
collected 53 items                                                      

tests/test_cli.py ................                                [ 30%]
tests/test_cogeo.py ..................                            [ 64%]
tests/test_profile.py .............                               [ 88%]
tests/test_utils.py .                                             [ 90%]
tests/test_validate.py ..                                         [ 94%]
tests/test_web.py ...                                             [100%]

=========================== warnings summary ============================
rio_cogeo/profiles.py:183
tests/test_profile.py::test_profiles_webp
  /webodm/tmp/rio-cogeo/rio_cogeo/profiles.py:183: UserWarning: Non-standard compression schema: webp. The output COG might not be fully supported by software not build against latest libtiff.
    " supported by software not build against latest libtiff.".format(key)

tests/test_profile.py::test_profiles_lerc
  /webodm/tmp/rio-cogeo/rio_cogeo/profiles.py:183: UserWarning: Non-standard compression schema: lerc. The output COG might not be fully supported by software not build against latest libtiff.
    " supported by software not build against latest libtiff.".format(key)

tests/test_profile.py::test_profiles_lerc_deflate
  /webodm/tmp/rio-cogeo/rio_cogeo/profiles.py:183: UserWarning: Non-standard compression schema: lerc_deflate. The output COG might not be fully supported by software not build against latest libtiff.
    " supported by software not build against latest libtiff.".format(key)

tests/test_profile.py::test_profiles_lerc_zstd
  /webodm/tmp/rio-cogeo/rio_cogeo/profiles.py:183: UserWarning: Non-standard compression schema: lerc_zstd. The output COG might not be fully supported by software not build against latest libtiff.
    " supported by software not build against latest libtiff.".format(key)

tests/test_validate.py::test_cog_validate_valid
  /usr/local/lib/python3.6/site-packages/rasterio/__init__.py:219: NotGeoreferencedWarning: Dataset has no geotransform set. The identity matrix may be returned.
    s = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
==================== 53 passed, 6 warnings in 5.85s =====================

# Transfer color interpolation
ci = vrt_dst.colorinterp
if nodata is None and not alpha:
ci = [c for c in ci if c != ColorInterp.alpha]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand this part to be honest!

Copy link
Contributor Author

@pierotofy pierotofy Dec 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started writing an explanation, and then realized that it's not needed. I was thinking that for the cases where add_alpha=True when creating the VRT I needed to remove the alpha band reference (that doesn't seem to be the case). I'll remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so something like

                if len(indexes) == 1:
                    tmp_dst.colorinterp = [ColorInterp.gray]
                else:
                    tmp_dst.colorinterp = [vrt_dst.colorinterp[b - 1] for b in indexes]

should be enough then

if nodata is None and not alpha:
ci = [c for c in ci if c != ColorInterp.alpha]
if indexes:
if len(indexes) == 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add

    if isinstance(indexes, int):
        indexes = (indexes,)

at the beginning of the script (L118) so indexes is always a tuple or a list

@pierotofy
Copy link
Contributor Author

Changes made 👍

@vincentsarago
Copy link
Member

thanks @pierotofy, This now lives in #117

@pierotofy
Copy link
Contributor Author

Fantastic! Thanks @vincentsarago 🥇

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

Successfully merging this pull request may close these issues.

pass colorinterp from input file
2 participants