How can I get all the images from area of interest in desired time period?

Home > Frequently Asked Questions > How can I get all the images from area of interest in desired time period?

Use Sentinel Hub WFS request and retrieve all relevant geometries for 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 bellow.

<script>
        // using Sentinel Hub OGC web services - http://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 = `http://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 - http://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 - http://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 = `http://services.sentinel-hub.com/ogc/wcs/${window.SENTINEL_HUB_INSTANCE_ID}
                ?service=WCS&version=1.1.2&request=GetCoverage&time=${date}&coverage=
                ${window.layerName}&nicename=${niceName}&bbox=${window.bbox}`;
                images.push(imageUrl);
            });

            shout(images);
        });

        let shout = value => {
            console.log('Images', value);
        }
    </script>