Use Sentinel Hub WFS request** and retrieve all relevant geometries for a given bounding box and time frame. From the response gather the unique dates. For each date, construct a WCS request to retrieve the image.
See the code example below:
<script>
// using Sentinel Hub OGC web services - https://www.sentinel-hub.com/develop/capabilities/wms
// config
window.SENTINEL_HUB_INSTANCE_ID = '<SENTINEL_HUB_INSTANCE_ID>';
window.layerName = '1_NATURAL_COLOR';
window.from = '2015-01-01';
window.to = '2017-04-20';
window.bbox = '-410925.4640611076,4891969.810251283,-391357.58482010243,4911537.689492286';
window.maxFeatures = 100; // 100 is max
let images = [];
let url = `https://services.sentinel-hub.com/ogc/wfs/${window.SENTINEL_HUB_INSTANCE_ID}?service=WFS&version=2.0.0&request=GetFeature&time=${window.from}/${window.to}/P1D&typenames=TILE&maxfeatures=${window.maxFeatures}&srsname=EPSG:3857&bbox=${window.bbox}&outputformat=application/json`;
(async () => {
// retrieving
// relevant geometries/images in bbox at time from-to
// Sentinel Hub - WFS request - https://www.sentinel-hub.com/develop/documentation/api/ogc_api/wfs-request
try {
let response = await fetch(url);
let data = await response.json();
relevantGeometries = data;
return data;
} catch (e) {
throw new Error('There was an error fetching the list of geometries from WFS service.\nDid you substitute your SENTINEL_HUB_INSTANCE_ID?');
}
})().then(geometries => {
// parsing
// relevant geometries -> all relevant dates
if(geometries.features === undefined) geometries.features = []
let dates = new Set();
geometries.features.forEach(value => {
dates.add(value.properties.date)
});
return Array.from(dates);
}).then(dates => {
// mapping
// dates -> image url
// images available via WCS request - https://www.sentinel-hub.com/develop/documentation/api/ogc_api/wcs-request
dates.forEach(date => {
let niceName = `${window.layerName} from ${date}.tiff`;
niceName = encodeURIComponent(niceName);
let imageUrl = `https://services.sentinel-hub.com/ogc/wcs/${window.SENTINEL_HUB_INSTANCE_ID}?service=WCS&version=1.1.2&request=GetCoverage&time=${date}&acoverage=${window.layerName}&nicename=${niceName}&bbox=${window.bbox}`;
images.push(imageUrl);
});
shout(images);
});
let shout = value => {
console.log('Images', value);
}
</script>
Comments
Article is closed for comments.