Git Product home page Git Product logo

Comments (2)

perrygeo avatar perrygeo commented on June 15, 2024

Also seeing the same bug on an existing 4-band test fixture

$ rio alpha tests/fixtures/ca_chilliwack/13-1326-2805-test-2015-2012_30cm_592_5450.tif /tmp/foo.tif

There's a couple ways to approach this:

As a bug in alpha_mask.mask_exact

We are rolling the axis to the depth (number of bands) when we should be using the number of dimensions which is almost always three. The fact that most inputs happened to have 3 bands was a coincidence that hid this bug. https://github.com/mapbox/rio-alpha/blob/master/rio_alpha/alpha_mask.py#L20-L21

Why np.rollaxis?

If we need to transpose the array to band-last/image axis order, we should use numpy.transpose which is roughly 3x faster and easier to read

np.transpose(img, [1, 2, 0])

Alpha band should take precedent

The bigger question is why are we even doing ndv masking calculations at all if the dataset has an alpha band? Per the conversation at #9 (comment), we should rely on rasterio's heuristics to generate the nodata mask. IOW, the usage of the mask_exact function could be replaced entirely with Rasterio's .dataset_mask() method.

from rio-alpha.

perrygeo avatar perrygeo commented on June 15, 2024

Another related bug, if we fix mask_exact, rio alpha assumes that it can stack the mask on the bottom of the existing array. IOW, If we start with a 4 band array, we get 5 bands which can't be written by rasterio.

from rio-alpha.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.