Skip to content

Commit

Permalink
include colormap json file
Browse files Browse the repository at this point in the history
  • Loading branch information
smohiudd committed Nov 27, 2024
1 parent c2337f3 commit a215fe0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion raster_api/runtime/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

inst_reqs = [
"boto3",
"rio-tiler==6.5.0",
"rio-tiler==7.2.2",
"titiler.pgstac==1.3.0",
"titiler.core>=0.18.5,<0.19",
"titiler.mosaic>=0.18.5,<0.19",
Expand Down
11 changes: 4 additions & 7 deletions raster_api/runtime/src/cmap_data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ np.save("soil_texture.npy", cmap)

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

# Colormap for Enhanced Fujita (EF) scale ratings
tornado_ef_scale = {
Expand All @@ -128,10 +128,7 @@ tornado_ef_scale = {
"5": "#ff00ff"
}

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

np.save("tornadoes.npy", cmap)
```
with open('tornado_ef_scale.json', 'w') as f:
json.dump(cmap, f)
1 change: 1 addition & 0 deletions raster_api/runtime/src/cmap_data/tornado_ef_scale.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"-1": [179, 188, 201, 255], "0": [173, 216, 230, 255], "1": [144, 238, 144, 255], "2": [255, 231, 31, 255], "3": [255, 165, 0, 255], "4": [255, 0, 0, 255], "5": [255, 0, 255, 255]}
Binary file removed raster_api/runtime/src/cmap_data/tornadoes.npy
Binary file not shown.
3 changes: 2 additions & 1 deletion raster_api/runtime/src/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
# Try backported to PY<39 `importlib_resources`.
from importlib_resources import files as resources_files # type: ignore


VEDA_CMAPS_FILES = {
f.stem: str(f) for f in (resources_files(__package__) / "cmap_data").glob("*.npy") # type: ignore
f.stem: str(f) for f in (resources_files(__package__) / "cmap_data").glob("*.[npy json]*") # type: ignore
}
cmap = default_cmap.register(VEDA_CMAPS_FILES)
ColorMapParams = create_colormap_dependency(cmap)

0 comments on commit a215fe0

Please sign in to comment.