Skip to content

Commit 02617ac

Browse files
committed
update rendering docs
1 parent 247da5d commit 02617ac

File tree

1 file changed

+52
-33
lines changed

1 file changed

+52
-33
lines changed

docs/src/advanced/rendering.md

Lines changed: 52 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,22 @@ Titiler supports both default colormaps (each with a name) and custom color maps
1616

1717
### Default Colormaps
1818

19-
Default colormaps pre-made, each with a given name. These maps come from the `rio-tiler` library, which has taken colormaps packaged with Matplotlib and has added others that are commonly used with raster data.
19+
Default colormaps pre-made, each with a given name. These maps come from the `rio-tiler` library, which has taken colormaps packaged with Matplotlib and has added others that are commonly used with raster data.
2020

2121
A list of available color maps can be found in Titiler's Swagger docs, or in the [rio-tiler documentation](https://cogeotiff.github.io/rio-tiler/colormap/#default-rio-tilers-colormaps).
2222

2323
To use a default colormap, simply use the parameter `colormap_name`:
2424

25-
```python3
26-
import requests
25+
```python
26+
import httpx
2727

28-
resp = requests.get("titiler.xyz/cog/preview", params={
29-
"url": "<YOUR COG HERE>",
30-
"colormap_name": "<YOUR COLORMAP NAME HERE>" # e.g. autumn_r
31-
})
28+
resp = httpx.get(
29+
"https://titiler.xyz/cog/preview",
30+
params={
31+
"url": "<YOUR DATASET URL HERE>",
32+
"colormap_name": "<YOUR COLORMAP NAME HERE>" # e.g. autumn_r
33+
}
34+
)
3235
```
3336

3437
You can take any of the colormaps listed on `rio-tiler`, and add `_r` to reverse it.
@@ -37,19 +40,19 @@ You can take any of the colormaps listed on `rio-tiler`, and add `_r` to reverse
3740

3841
If you'd like to specify your own colormap, you can specify your own using an encoded JSON:
3942

40-
```python3
41-
import requests
43+
```python
44+
import httpx
4245

43-
response = requests.get(
44-
f"titiler.xyz/cog/preview",
46+
response = httpx.get(
47+
"https://titiler.xyz/cog/preview",
4548
params={
46-
"url": "<YOUR COG HERE>",
49+
"url": "<YOUR DATASET URL HERE>",
4750
"bidx": "1",
48-
"colormap": {
49-
"0": "#e5f5f9",
50-
"10": "#99d8c9",
51-
"255": "#2ca25f",
52-
}
51+
"colormap": json.dumps({
52+
"0": "#e5f5f9",
53+
"10": "#99d8c9",
54+
"255": "#2ca25f",
55+
})
5356
}
5457
)
5558
```
@@ -75,13 +78,13 @@ Titiler supports color formulae as defined in [Mapbox's `rio-color` plugin](http
7578

7679
In Titiler, color_formulae are applied through the `color_formula` parameter as a string. An example of this option in action:
7780

78-
```python3
79-
import requests
81+
```python
82+
import httpx
8083

81-
response = requests.get(
82-
f"titiler.xyz/cog/preview",
84+
response = httpx.get(
85+
"https://titiler.xyz/cog/preview",
8386
params={
84-
"url": "<YOUR COG HERE>",
87+
"url": "<YOUR DATASET URL HERE>",
8588
"color_formula": "gamma rg 1.3, sigmoidal rgb 22 0.1, saturation 1.5"
8689
}
8790
)
@@ -91,25 +94,41 @@ response = requests.get(
9194

9295
Rescaling is the act of adjusting the minimum and maximum values when rendering an image. In an image with a single band, the rescaled minimum value will be set to black, and the rescaled maximum value will be set to white. This is useful if you want to accentuate features that only appear at a certain pixel value (e.g. you have a DEM, but you want to highlight how the terrain changes between sea level and 100m).
9396

94-
Titiler supports rescaling on a per-band basis, using the `rescaling` parameter. The input is a list of comma-delimited min-max ranges (e.g. ["0,100", "100,200", "0,1000]).
97+
All titiler endpoinds returning *image* support `rescale` parameter. The parameter should be in form of `"rescale={min},{max}"`.
9598

96-
```python3
97-
import requests
99+
```python
100+
import httpx
98101

99-
response = requests.get(
100-
f"titiler.xyz/cog/preview",
102+
response = httpx.get(
103+
"https;//titiler.xyz/cog/preview",
101104
params={
102-
"url": "<YOUR COG HERE>",
103-
"rescaling": ["0,100", "0,1000", "0,10000"]
104-
}
105+
"url": "<YOUR DATASET URL HERE>",
106+
"rescale": "0,100",
107+
},
108+
)
109+
```
110+
111+
Titiler supports rescaling on a per-band basis, using multiple `rescale` parameters.
112+
113+
```python
114+
import httpx
115+
116+
response = httpx.get(
117+
"https;//titiler.xyz/cog/preview",
118+
params=(
119+
("url", "<YOUR DATASET URL HERE>"),
120+
("rescale", "0,100"),
121+
("rescale", "0,1000"),
122+
("rescale", "0,10000"),
123+
),
105124
)
106125
```
107126

108127
By default, Titiler will rescale the bands using the min/max values of the input datatype. For example, PNG images 8- or 16-bit unsigned pixels,
109-
giving a possible range of 0 to 255 or 0 to 65,536, so Titiler will use these ranges to rescale to the output format.
128+
giving a possible range of 0 to 255 or 0 to 65,536, so Titiler will use these ranges to rescale to the output format.
110129

111-
For certain datasets (e.g. DEMs) this default behaviour can make the image seem washed out (or even entirely one color),
130+
For certain datasets (e.g. DEMs) this default behaviour can make the image seem washed out (or even entirely one color),
112131
so if you see this happen look into rescaling your images to something that makes sense for your data.
113132

114133
It is also possible to add a [rescaling dependency](../../api/titiler/core/dependencies/#rescalingparams) to automatically apply
115-
a default rescale.
134+
a default rescale.

0 commit comments

Comments
 (0)