developmentseed / titiler

Build your own Raster dynamic map tile services
https://developmentseed.org/titiler/
MIT License
755 stars 156 forks source link

Incorrect documentation example for custom colormaps #788

Closed robintw closed 5 months ago

robintw commented 6 months ago

Problem description

The custom colormaps section of the documentation gives an example of:

response = requests.get(
    f"titiler.xyz/cog/preview",
    params={
        "url": "<YOUR COG HERE>",
        "bidx": "1",
        "colormap": {
                "0": "#e5f5f9",
                "10": "#99d8c9",
                "255": "#2ca25f",
            }
    }
)

It seems to be impossible to send JSON parameters in the params dict using request, and this led to various errors from inside the rio-tiler code complaining that the colormap was just the number 0.

I managed to fix this by changing it to:

response = requests.get(
    f"titiler.xyz/cog/preview",
    params={
        "url": "<YOUR COG HERE>",
        "bidx": "1",
        "colormap": json.dumps({
                "0": "#e5f5f9",
                "10": "#99d8c9",
                "255": "#2ca25f",
            })
    }
)

Is this the correct way to solve this? If so, I'm happy to do a PR to fix the docs, but I wanted to check first.

vincentsarago commented 5 months ago

fixed in https://github.com/developmentseed/titiler/commit/02617ac5af5e6ab995a6873420213ac945fd65a6