m_sig
(M. SIG)
October 15, 2024, 3:23pm
1
How to consume ESA Worldcover (ESA WorldCover - Sentinel Hub Collections ) on a web page with javascript?
I can already consume and present sentinel and landsat layers normally, but now I’m trying to consume some of these collections (https://collections.sentinel-hub.com/ )
Can anyone show me a simple example code?
gmilcinski
(Grega Milcinski)
October 15, 2024, 4:01pm
2
You will need to refer to a specific collection, see “Type” here:
https://collections.sentinel-hub.com/worldcover/
An example of a request:
curl -X POST https://services.sentinel-hub.com/api/v1/process \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <AUTH_TOKEN>' \
-d '{
"input": {
"bounds": {
"bbox": [
12.44693,
41.870072,
12.541001,
41.917096
]
},
"data": [
{
"dataFilter": {
"timeRange": {
"from": "2021-01-01T00:00:00Z",
"to": "2021-01-01T23:59:59Z"
}
},
"type": "byoc-0b940c63-45dd-4e6b-8019-c3660b81b884"
}
]
},
"output": {
"width": 512,
"height": 343.697,
"responses": [
{
"identifier": "default",
"format": {
"type": "image/jpeg"
}
}
]
},
"evalscript": "//VERSION=3\n\n// This custom script visualises WorldCover map \n\nfunction setup() {\n return {\n input: [\"Map\", \"dataMask\"],\n output: { \n bands: 4, \n sampleType: \"AUTO\"\n }\n }\n}\n\nconst map = [\n [10, 0x006400], // Tree cover\n [20, 0xffbb22], // Shrubland\n [30, 0xffff4c], // Grassland\n [40, 0xf096ff], // Cropland\n [50, 0xfa0000], // Built up\n [60, 0xb4b4b4], // Bare / sparse vegetation\n [70, 0xf0f0f0], //\tSnow and Ice\n [80, 0x0064c8], //\tPermanent water bodies\n [90, 0x0096a0], //\tHerbaceous wetland\n [95, 0x00cf75], //\tMangroves\n [100, 0xfae6a0], //\tMoss and lichen\n \n ];\n\nconst visualizer = new ColorMapVisualizer(map);\n\nfunction evaluatePixel(sample) {\n return [visualizer.process(sample.Map)[0], visualizer.process(sample.Map)[1], visualizer.process(sample.Map)[2], sample.dataMask];\n}\n"
}'
m_sig
(M. SIG)
October 15, 2024, 6:00pm
3
This is the result (all green) when I try to consume ESA Worldcoper
gmilcinski
(Grega Milcinski)
October 15, 2024, 8:00pm
4
Might it be the chosen area is simply vegetation?
If I paste the request above in Request Builder, I get various colors:
Also, make sure you also use the correct time range, if you use the same time range as Grega’s request you should return back the World Cover data.
1 Like
m_sig
(M. SIG)
October 17, 2024, 1:01pm
6
Nice. The problem was the time range. Thanks.