0

I have a tif file in COG format which I am trying to render on browser using deckgl. I am using titiler based server for serving the file.

When I have data url as:

data: 'http://localhost:8001/cog/tiles/WebMercatorQuad/{z}/{x}/{y}.png?url=http://localhost/cog/sgnp_fcd_3857_cog.tif&rescale=0,100'

....image is rendered as expected.

enter image description here

When I also pass titiler's inbuild colormap 'rdylgn':

data: 'http://localhost:8001/cog/tiles/WebMercatorQuad/{z}/{x}/{y}.png?url=http://localhost/cog/sgnp_fcd_3857_cog.tif&rescale=0,100&colormap_name=rdylgn'

....again image is rendered as expected.

enter image description here

Now, I add my custom color map:

from fastapi import FastAPI from rio_tiler.colormap import cmap as default_cmap from titiler.core.dependencies import create_colormap_dependency from titiler.core.factory import TilerFactory, ColorMapFactory from starlette.middleware.cors import CORSMiddleware app = FastAPI() FCD_INTERVAL_COLORMAP = [ ((0, 15), (215, 25, 28, 255)), # 0-20: Red ((15, 20), (254,196,123, 255)), # 20-40: Orange ((20, 40), (237,247,174, 255)), # 40-60: Yellow ((40, 60), (156,212,103, 255)), # 60-80: Light green ((60, 80), (91, 181, 84, 255)), # 80-100: Blue ((80, 100), (26, 150, 65, 255)), # 80-100: Blue ] cmap = default_cmap.register({"fcd_intervals": FCD_INTERVAL_COLORMAP}) ColorMapParams = create_colormap_dependency(cmap) colormap = ColorMapFactory(supported_colormaps=cmap) app.include_router(colormap.router) cog = TilerFactory(colormap_dependency=ColorMapParams) app.include_router(cog.router, prefix="/cog", tags=["COG"]) @app.get("/") def read_index(): return {"message": "Welcome to TiTiler"} 

..this renders image like:

enter image description here

This is not what I expected. First, colors itself are pretty different from what are defined in colormap, like water bodies are supposed to be red as their raster value is below 15, but in image they are light green. Second, majority of the image seems to have gone transparent with underlying map visible.

What mistake have I made in my colormap code?

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.