Skip to main content

Hello,

My application collects some satellite data using your platform and sentinelhub-js library. I am able to download geotiff that gather 300 dates and 7 samples per pixel(in total: 300 * 7 = 2100 bands). Unfortunately decompression of the fetched geotiff lasts about 20 minutes(to perform decompression I use geotiff.js).

This takes definitely too much time. Is there any possibility to improve the way the data is retrieved in order to decrease decompression time?

Or maybe can I get a set of PNGs(each sample per each date as a separate PNG) or Buffer instead of geotiff and skip the whole process of decompression?

Perhaps there is a possibility to retrieve data as separate tiff pages?


Here is code for retrieve data from sentinel:


const rawDataLayer = new S2L2ALayer({
instanceId: process.env.INSTANCE_ID,
layerId: "TRUE-COLOR-S2L2A",
evalscript: rawDataEvalscript(dates),
mosaickingOrder: MosaickingOrder.LEAST_RECENT,
});

const getMapParams = {
bbox,
geometry,
fromTime,
toTime,
transparent: true,
resx: "10m",
resy: "10m",
format: "image/tiff",
};
let imageBlob = (await rawDataLayer.getMap(getMapParams, ApiType.WMS)) as any as Buffer;

const BANDS_COUNT = 7;

export const rawDataEvalscript = (dates: Date[]) => {
const datesCount = dates.length;
const bandsCount = BANDS_COUNT * datesCount;

return `
//VERSION=3

function setup() {
return {
input: ["B08", "B04", "B03", "B02", "dataMask", "SCL", "CLM"],
output: [
{
id: "default",
bands: ${bandsCount},
sampleType: "UINT8"
},
],
mosaicking: "ORBIT"
};
}

const dates = [${dates.map((date) => `"${date.toISOString().split("T")[0]}"`).join(", ")}];

function evaluatePixel(samples, scenes) {
let data = []
let length = samples.length
for (let i = 0; i < samples.length; i++) {
const date = scenes.orbits[i].dateFrom.split("T")[0]
if (!dates.includes(date)) continue;
data.push(samples[i].B08 * 255)
data.push(samples[i].B04 * 255)
data.push(samples[i].B03 * 255)
data.push(samples[i].B02 * 255)
data.push(samples[i].dataMask * 255)

data.push(samples[i].SCL)
data.push(samples[i].CLM)

}

return data
}
`;
};

And the code for extracting bands from tiff :
const rasters = await image.readRasters({ interleave: true }); - this line runs about 20 minutes


   const buffer = await new Response(imageBlob).arrayBuffer();
const geotiff = await fromArrayBuffer(buffer);
const image = await geotiff.getImage();
const rasters = await image.readRasters({ interleave: true });

Hi,

As you are requesting so many bands, this sounds like expected behaviour when decompressing them. Perhaps it would make more sense to request shorter time periods, splitting up your request into several requests and then decompressing the smaller and manageable file sizes.


Reply