Hello Sentinel Forum Community,
I am currently working on fetching PlanetScope imagery using the Sentinel API, and I’ve encountered an issue with the structure of my evalscript in the response. I’m hoping to get some guidance on how to properly structure the evalscript for my use case.
Here’s the evalscript I’m using:
//VERSION=3
function setup() {
return {
input: [{ bands: ['B04', 'B08'] }],
output: [{ id: 'default', bands: 1, sampleType: 'FLOAT32' }],
};
}
function evaluatePixel(sample) {
let ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04);
return { default: [ndvi] };
}
(the idea of doing this is to be able to categorize the color indexes based on certain ranges between -1 and 1, like we do with sentinel 2 imagery)
However, when I make the request, I'm encountering the following error:
{
"error": {
"status": 400,
"reason": "Bad Request",
"message": "Collection 'byoc-???????' has no band 'B04'.",
"code": "RENDERER_EXCEPTION"
}
}
Here's the relevant part of my fetch request:
const requestData = new FormData();
evalscript = `//VERSION=3
// ... (the evalscript remains the same)
`;
requestData.append(
'request',
JSON.stringify({
input: {
bounds: {
properties: { crs: 'http://www.opengis.net/def/crs/OGC/1.3/CRS84' },
geometry: {
type: 'Polygon',
coordinates: [polygonCoordinates],
},
},
data: [
{
type: 'byoc-xxxx2dfe',
dataFilter: {
timeRange: {
from: "2020-04-21T00:00:00Z",
to: "2021-04-21T23:59:59Z"
}
},
},
],
},
output: { responses: [{ identifier: 'default', format: { type: 'image/tiff' } }] },
})
);
Could someone please guide me on how to structure the evalscript correctly to avoid this error? I’m looking to compute NDVI from bands ‘B04’ and ‘B08’.
Thank you in advance for your assistance!