Skip to content

Commit

Permalink
feat(raster): added new soil texture colormap (#442)
Browse files Browse the repository at this point in the history
### Issue

#441

### What/Why?
Add a custom colormap to titiler for soil texture datasets. The source
parameter definition of the color mappings would otherwise be too long
for firewall restrictions.

### Testing?
I ran the titiler locally and previewed the results for one soil texture
COG.

<img width="1414" alt="soil-texture-preview"
src="https://github.com/user-attachments/assets/63b50994-af0c-47a4-8004-b792a3d0848b">
  • Loading branch information
anayeaye authored Oct 23, 2024
2 parents a226793 + c84d1d0 commit b633276
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions raster_api/runtime/src/cmap_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,33 @@ for c, v in internal_colormap.items():

np.save("nlcd.npy", cmap)
```

##### Soil texture colormap

```python
from rio_tiler.colormap import parse_color
import numpy as np

# These categories are based on a USGS soil texture chart, not an official set of color mappings for soil texture categories
texture_categories = {
"1": "#F89E61",
"2": "#BA8560",
"3": "#D8D2B4",
"4": "#AE734C",
"5": "#9E8478",
"6": "#C6A365",
"7": "#B4A67D",
"8": "#E1D4C4",
"9": "#BEB56D",
"10": "#777C7A",
"11": "#A89B6F",
"12": "#E9E2AF"
}

cmap = np.zeros((256, 4), dtype=np.uint8)
cmap[:] = np.array([0, 0, 0, 255])
for k in texture_categories.keys():
cmap[int(k)] = np.array(parse_color(texture_categories[k]))

np.save("soil_texture.npy", cmap)
```
Binary file added raster_api/runtime/src/cmap_data/soil_texture.npy
Binary file not shown.

0 comments on commit b633276

Please sign in to comment.