Skip to content

Commit

Permalink
add colormap
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed Dec 17, 2024
1 parent 7a45834 commit 735db4d
Show file tree
Hide file tree
Showing 6 changed files with 399 additions and 10 deletions.
226 changes: 219 additions & 7 deletions services/eoapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@
"tile_size": 256,
"minzoom": 12,
"maxzoom": 19,
"extent": [29.987132801982625, 31.587422555628876, -30.8587632892144, -28.886191362214085]
"extent": [29.987132801982625, -30.8587632892144, 31.587422555628876, -28.886191362214085]
},
"enabled": true,
"process": {
Expand Down Expand Up @@ -401,6 +401,12 @@
"inputMax": 5000,
"outputMin": 0,
"outputMax": 255
}
},
"trunc": {
"process_id": "trunc",
"arguments": {
"x": {"from_node": "linear1"}
},
"result": true
}
Expand Down Expand Up @@ -433,7 +439,7 @@
"tile_size": 256,
"minzoom": 12,
"maxzoom": 19,
"extent": [29.987132801982625, 31.587422555628876, -30.8587632892144, -28.886191362214085]
"extent": [29.987132801982625, -30.8587632892144, 31.587422555628876, -28.886191362214085]
},
"enabled": true,
"process": {
Expand Down Expand Up @@ -490,6 +496,12 @@
"inputMax": 1,
"outputMin": 0,
"outputMax": 255
}
},
"trunc": {
"process_id": "trunc",
"arguments": {
"x": {"from_node": "linear1"}
},
"result": true
}
Expand Down Expand Up @@ -522,7 +534,7 @@
"tile_size": 256,
"minzoom": 12,
"maxzoom": 19,
"extent": [29.987132801982625, 31.587422555628876, -30.8587632892144, -28.886191362214085]
"extent": [29.987132801982625, -30.8587632892144, 31.587422555628876, -28.886191362214085]
},
"enabled": true,
"process": {
Expand Down Expand Up @@ -604,11 +616,17 @@
"outputMax": 255
}
},
"trunc": {
"process_id": "trunc",
"arguments": {
"x": {"from_node": "linear_scale_range"}
}
},
"save5": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "linear_scale_range"
"from_node": "trunc"
},
"format": "PNG"
},
Expand All @@ -629,7 +647,7 @@
"tile_size": 256,
"minzoom": 12,
"maxzoom": 19,
"extent": [29.987132801982625, 31.587422555628876, -30.8587632892144, -28.886191362214085]
"extent": [29.987132801982625, -30.8587632892144, 31.587422555628876, -28.886191362214085]
},
"enabled": true,
"process": {
Expand Down Expand Up @@ -696,8 +714,8 @@
"tile_size": 256,
"minzoom": 12,
"maxzoom": 19,
"extent": [29.987132801982625,-31.587422555628876, 30.8587632892144, -28.886191362214085]
},
"extent": [29.987132801982625, -30.8587632892144, 31.587422555628876, -28.886191362214085]
},
"enabled": true,
"process": {
"process_graph": {
Expand Down Expand Up @@ -752,5 +770,199 @@
"parameters": []
}
}
},
"48ce6183-d431-4625-b492-ab2f1b63c00a": {
"user_id": "12d6b89f-0f26-4fe7-a461-67418919b794",
"service": {
"id": "48ce6183-d431-4625-b492-ab2f1b63c00a",
"title": "South-Africa Flooding 2022 - NDVI - Viridis",
"type": "XYZ",
"configuration": {
"tile_size": 256,
"minzoom": 12,
"maxzoom": 19,
"extent": [29.987132801982625, -30.8587632892144, 31.587422555628876, -28.886191362214085]
},
"enabled": true,
"process": {
"process_graph": {
"load1": {
"process_id": "load_collection_and_reduce",
"arguments": {
"bands": [
"ms_analytic"
],
"properties": {},
"id": "MAXAR_southafrica_flooding22",
"spatial_extent": {
"east": {
"from_parameter": "spatial_extent_east"
},
"north": {
"from_parameter": "spatial_extent_north"
},
"south": {
"from_parameter": "spatial_extent_south"
},
"west": {
"from_parameter": "spatial_extent_west"
}
},
"temporal_extent": [
"2022-04-21T00:00:00Z",
"2022-05-01T00:00:00Z"
]
}
},
"ndvi": {
"process_id": "ndvi",
"arguments": {
"data": {
"from_node": "load1"
},
"nir": 8,
"red": 1
}
},
"apply4": {
"process_id": "apply",
"arguments": {
"data": {"from_node": "ndvi"},
"process": {
"process_graph": {
"linear1": {
"process_id": "linear_scale_range",
"arguments": {
"x": {"from_parameter": "x"},
"inputMin": -1,
"inputMax": 1,
"outputMin": 0,
"outputMax": 255
}
},
"trunc": {
"process_id": "trunc",
"arguments": {
"x": {"from_node": "linear1"}
},
"result": true
}
}
}
}
},
"cmap": {
"process_id": "get_colormap",
"arguments": {
"name": "viridis"
}
},
"colormap1": {
"process_id": "colormap",
"arguments": {
"data": {
"from_node": "apply4"
},
"colormap": {
"from_node": "cmap"
}
}
},
"save5": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "colormap1"
},
"format": "PNG"
},
"result": true
}
},
"parameters": []
}
}
},
"b9cb48ae-f210-401d-a644-859deefafb18": {
"user_id": "12d6b89f-0f26-4fe7-a461-67418919b794",
"service": {
"id": "b9cb48ae-f210-401d-a644-859deefafb18",
"title": "South-Africa Flooding 2022 - NDVI - Custom ColorMap",
"type": "XYZ",
"configuration": {
"tile_size": 256,
"minzoom": 12,
"maxzoom": 19,
"extent": [29.987132801982625, -30.8587632892144, 31.587422555628876, -28.886191362214085]
},
"enabled": true,
"process": {
"process_graph": {
"load1": {
"process_id": "load_collection_and_reduce",
"arguments": {
"bands": [
"ms_analytic"
],
"properties": {},
"id": "MAXAR_southafrica_flooding22",
"spatial_extent": {
"east": {
"from_parameter": "spatial_extent_east"
},
"north": {
"from_parameter": "spatial_extent_north"
},
"south": {
"from_parameter": "spatial_extent_south"
},
"west": {
"from_parameter": "spatial_extent_west"
}
},
"temporal_extent": [
"2022-04-21T00:00:00Z",
"2022-05-01T00:00:00Z"
]
}
},
"ndvi": {
"process_id": "ndvi",
"arguments": {
"data": {
"from_node": "load1"
},
"nir": 8,
"red": 1
}
},
"colormap1": {
"process_id": "colormap",
"arguments": {
"data": {
"from_node": "ndvi"
},
"colormap": [
[[-2, -1], [0, 255, 0, 255]],
[[-1, 0], [0, 255, 0, 255]],
[[0, 0.5], [255, 0, 0, 255]],
[[0.5, 1.1], [255, 255, 0, 255]]
]
}
},
"save5": {
"process_id": "save_result",
"arguments": {
"data": {
"from_node": "colormap1"
},
"format": "PNG"
},
"result": true
}
},
"parameters": []
}
}
}
}
81 changes: 81 additions & 0 deletions titiler/openeo/processes/data/colormap.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"id": "colormap",
"summary": "Apply a color formula to an image.",
"description": "Return Image data with a colormap applied.",
"categories": [
"images",
"color"
],
"parameters": [
{
"name": "data",
"description": "An image.",
"schema": {
"type": "object",
"subtype": "imagedata"
}
},
{
"name": "colormap",
"description": "The colormap to apply.",
"schema": [
{
"title": "GDAL ColorMap",
"description":"An GDAL defined colormap in form of `{val: (r, g, b, alpha), ...}`.",
"type": "object",
"patternProperties": {
"^[0-9]+$": {
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": {
"type": "number"
}
}
}
},
{
"title": "Interval ColorMap",
"description":"An Interval colormap in form of `[[(min, max), (r, g, b, alpha)], ...]`.",
"type": "array",
"minItems": 1,
"items": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "array",
"prefixItems": [
{
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "number"
}
},
{
"type": "array",
"minItems": 4,
"maxItems": 4,
"items": {
"type": "number"
}
}
]
}
}
}
]
}
],
"returns": {
"description": "The image with the colormap applied.",
"schema": {
"type": "object",
"subtype": "imagedata"
}
},
"exceptions": {},
"examples": []
}
Loading

0 comments on commit 735db4d

Please sign in to comment.