Comments (2)
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.
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)
- Update Readme + docstrings HOT 1
- port pxm-alpha
- Standardize nodata value output format HOT 2
- Blocksize is already a creation option HOT 1
- NDV list input is not clear HOT 1
- islossy CLI should return True or False HOT 1
- Opensource this repo HOT 1
- findnodata --debug requires matplotlib HOT 1
- _convert_rgb uses integer division
- Convert between different nodata representations? HOT 2
- axis entry is out of bounds HOT 1
- 0.6 release HOT 2
- pydocstyle reports 10 missing docstrings
- Make _alpha_worker public
- 1.0.0 release HOT 3
- Reformat
- 1.0.1 release HOT 1
- 1.0.2 release
- different ways to represent nodata HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rio-alpha.