Comments (4)
👋 Hi @kriscarle, thanks for opening this issue.
So to keep everything as simple as possible we could:
- add an option in
array_to_img
to apply a palette to a 1 band image (example). - add a
utils.get_palette
function that accept either a rasterio dataset (as ingeop
) or acolor_palette
name (local palettes shipped within rio-tiler)
btw, there are some work to do to fully support one band output image (e.g. add mask) : https://github.com/mapbox/rio-tiler/blob/f33930f4da0493c6941e5c3e617364eb9caca86a/rio_tiler/utils.py#L354-L355
from rio-tiler.
Hi @vincentsarago I was able to get it working like this, using rasterio's built in support for writing colormaps and MemoryFile. The PIL palette doesn't support RGBA values, plus I think this example can easily be adapted to support multiple bands.
import rasterio
from rio_tiler import aws
from rasterio.io import MemoryFile
def tile(event, context):
args = event['pathParameters']
x = int(args['x'])
y = int(args['y'])
z = int(args['z'])
bucket = 'my-bucket'
key = 'data.vrt'
tile = aws.tile(bucket, key, x, y, z, 1, 256)
with rasterio.open('s3://{}/{}'.format(bucket, key)) as src:
colormap = src.colormap(1)
meta = src.meta
meta['driver'] = 'PNG'
meta['height'] = 256
meta['width'] = 256
with MemoryFile() as memfile:
with memfile.open(**meta) as dataset:
dataset.write(tile, indexes=1)
dataset.write_colormap(1, colormap)
memfile.seek(0)
return memfile.read()
from rio-tiler.
@kriscarle I'm not sure to follow 100%
I made this notebook to try to explain my though.
Basically your example does not imply any change in rio_tiler
but it's more on the lambda handler side. What I think will be good is to add this in the documentation.
plus I think this example can easily be adapted to support multiple bands.
I'm not sure to understand the concept of applying color palette to multiple bands. I'll be interested to see any use case for that.
from rio-tiler.
Yes, I ended up not needing to change rio-tiler, so it could just work as an example. Though it could still be a nice feature to automatically apply the color map from a VRT band if it is provided in the VRT.
I'm not entirely sure what I meant by multiple bands either. I think I meant that you can create tiles for multiple bands and then combine them in some way. Maybe for calculating NVDI on the fly?
from rio-tiler.
Related Issues (20)
- 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
- Custom In-Memory Reader HOT 1
- nodata value being ignored HOT 3
- .tile() is not masking region outside of image when nodata used HOT 3
- Count default method? HOT 1
- Incorrect array statistics with (coverage) weights HOT 2
- Method to filter assets within mosaic_reader HOT 1
- Forwarding `ImageData.array.mask` in NPZ output HOT 4
- [STAC] access Alternate URL
- nodata value being ignored for NaN HOT 2
- Error applying expression with STACReader : "NumExpr 2 does not support Unicode as a dtype."
- Investigate higher HEAD/GET Request with GDAL >3.7 HOT 9
- replace deprecated `is_tiled`
- S3 STAC item may not load properly after pystac 1.10 HOT 2
- Better handle Dateline crossing Dataset
- refactor benchmark
- ImportError: cannot import name 'WEB_MERCATOR_TMS' from 'rio_tiler.constants'
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.