Comments (9)
👋 @a2hill sorry for this bug
I don't see a fix directly to the array_to_image
function but to me it seems you could pass indexes=(1,2,3)
to the main.tile
function and then the mask return should be the alpha band.
Handling nodata/mask/alpha band is a tricky thing (I've worked on the matter all the week), maybe utils.tile_read
could remove the alpha band from the data
array directly ?
Edits:
buffer = utils.array_to_image(tile, mask=mask, img_format="webp", color_map=None, **options)
Here you are also passing the mask
to the function, but the alpha band is already provided with your data, so you have two solution:
- uses
indexes=(1,2,3)
- don't pass
mask
to theutils.array_to_image
function
from rio-tiler.
@vincentsarago Yes we implemented additional check's for 4 band images and handle them differently. I think the older version of array_to_img
used a has_alpha
check, was that specific to PIL support?
from rio-tiler.
@a2hill where you able to have your code fixed ?
I'm going to close this issue, but feel free to re-open if you have more questions.
Note: I've added a note in #63 to add more documentation about nodata/alpha handling.
from rio-tiler.
@a2hill I'll need to check but maybe this
Line 537 in 9aa45d6
was taking care of it because it forced the data to be 3bands.
I'm kinda happy/not happy about the situation but I do believe that using the new gdal based function let's the user do more thing (e.g enable to save GeoTIFF). But maybe we still could add a test for data that have more than 3 bands and not saved as 'GTiff'.
from rio-tiler.
I agree, I like the new gdal based image function as well. I think it is going to be a lot more helpful with single band images as well. Previously I was having to do linear scaling to convert my dem's from float
to uint8
but it looks like I no longer will need to do that with the gdal based function? Thanks for the hard work!
from rio-tiler.
@a2hill well I think GDAL will throw an error if your data is not in uint8
, before we had a test to cast
the data to uint8 but again we removed it to let the user decide in their own implementation (mostly to support other format).
from rio-tiler.
Ah okay nevermind then! Related but kind of off topic, are you planning support to allow color_map files which use the GDAL color configuration syntax?
from rio-tiler.
@a2hill when I started working on the new function I tried to use the internal gdal method (https://github.com/mapbox/rasterio/blob/master/docs/topics/color.rst#writing-colormaps) but I couldn't get it to work (If I remember well my problem was that I had to first write the file to the disk before being able to see the colormap applied data.
I could have a second look later, but if you ever want to start a PR to update array_to_image
or add a new function, please feel free.
Also I'm also happy to see how people use rio-tiler 😄
from rio-tiler.
@vincentsarago Thanks for pointing that out. I may have a look at that as I am currently looking into integrating support for colorbrewer2 palettes via palettable for DEM's. If I find a better way to apply the color maps I'll be sure to submit a PR.
from rio-tiler.
Related Issues (20)
- The apply_color_formula function is failing to apply color_formula HOT 13
- Mask nodata values in XarrayReader's tile method
- update morecantile dependency to 4.0.0 (TMS 2.0)
- XarrayReader.tile returning `At least one of the clipped raster x,y coordinates has only one point.` HOT 2
- add pre-commit.ci
- `get_array_statistics` fails when data is fully masked HOT 2
- Information about STACReader fetch_options HOT 2
- Confusing error messages when expressions contain missing assets HOT 5
- Forward rasterio env options in multibase Reader HOT 2
- `NotGeoreferencedWarning` in `feature` HOT 2
- v6.0 break key access to Model
- Can't read file from private Google Cloud Storage Bucket HOT 2
- Interpolation should happen after masking HOT 1
- READER RETUNR NOT FOUND
- Reader `resampling_method` has no effect HOT 1
- Reader `resampling_method` has no effect when doing Reprojection HOT 2
- Investigate weird output resolution after #648 HOT 3
- remove usage of WarpedVRT?
- No colormapping support for float dtype HOT 1
- Worse image quality with tiles cut using rio-tiler than GDAL HOT 4
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-tiler.