Hi,
We are currently using @sentinel-hub/sentinelhub-js
in typescript.
Here is some code that should be enough to recreate the error.
import * as sentinelhub from '@sentinel-hub/sentinelhub-js';
import { MosaickingOrder } from '@sentinel-hub/sentinelhub-js';
import * as turf from '@turf/turf';
import { Polygon } from 'geojson';
type BBox2D = [number, number, number, number];
async function getImage() {
const polygon: Polygon = {
type: 'Polygon',
coordinates: [
[
[-80.352296979, 42.759124977],
[-80.335947457, 42.759124977],
[-80.335947457, 42.766406763],
[-80.352296979, 42.766406763],
[-80.352296979, 42.759124977],
],
],
};
const bbox = new sentinelhub.BBox(sentinelhub.CRS_WGS84, ...(turf.bbox(polygon) as BBox2D));
await sentinelhub.requestAuthToken(this.sentinelConfig.CLIENT_ID, this.sentinelConfig.CLIENT_SECRET);
const sentinelEvalscript = `
//VERSION=3
function setup() {
return{
input: [{
bands: ["B04", "B08"]
}],
output: {
id: "default",
bands: 1,
sampleType: SampleType.FLOAT32
}
}
}
function evaluatePixel(sample) {
let ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04)
return [ ndvi ]
}
`;
const s2L1CLayer = new sentinelhub.S2L1CLayer({
instanceId: this.sentinelConfig.INSTANCE_ID,
layerId: this.sentinelConfig.LAYER_ID,
evalscript: sentinelEvalscript,
maxCloudCoverPercent: 10,
mosaickingOrder: MosaickingOrder.MOST_RECENT,
title: 'NDVI_LAYER',
description: 'Layer used for getting ndvi index',
});
try {
const blob = await s2L1CLayer.getMap(
{
bbox,
geometry: polygon,
toTime: new Date(1654819200000),
resx: '10m',
resy: '10m',
preview: sentinelhub.PreviewMode.DETAIL,
format: 'image/tiff',
fromTime: null,
quality: 100,
},
sentinelhub.ApiType.WMS
);
return blob as undefined as Buffer;
} catch (error) {
console.log(error.response.data.toString());
throw error;
}
}
getImage();
Error occurs after getMap
function while getting image