Beispiel #1
0
    def request1(self):
        wcs_true_color_request = WcsRequest(
            layer='TRUE_COLOR',
            bbox=self._bbox,
            # time='2017-12-15',
            resx='10m',
            resy='10m',
            custom_url_params=self.customUrlParam,
            config=config)

        wcs_true_color_img = wcs_true_color_request.get_data()
        print('''Single element in the list is of type = {} and has shape {}
            '''.format(type(wcs_true_color_img[-1]),
                       wcs_true_color_img[-1].shape))
        plot_image(wcs_true_color_img[-1])
    def setUp(cls):
        super().setUpClass()

        bbox = BBox((111.7, 8.655, 111.6, 8.688), crs=CRS.WGS84)
        cls.request = WcsRequest(data_folder=cls.OUTPUT_FOLDER,
                                 bbox=bbox,
                                 layer='TRUE-COLOR-S2-L1C')
Beispiel #3
0
def get_DEM_request(dam_bbox, resx, resy):
    return WcsRequest(data_source=DataSource.DEM,
                      layer='DEM',
                      resx=f'{resx}m', resy=f'{resy}m',
                      bbox=dam_bbox,
                      image_format=MimeType.TIFF_d32f,
                      custom_url_params={CustomUrlParam.SHOWLOGO: False})
Beispiel #4
0
    def test_init(self):

        bbox = BBox((8.655, 111.7, 8.688, 111.6), crs=CRS.WGS84)
        data_request = WcsRequest(data_folder=self.OUTPUT_FOLDER,
                                  bbox=bbox,
                                  layer='BANDS-S2-L1C')

        self.assertEqual(self.OUTPUT_FOLDER,
                         data_request.data_folder,
                         msg="Expected {}, got {}".format(
                             self.OUTPUT_FOLDER, data_request.data_folder))
        self.assertTrue(isinstance(data_request.get_filename_list(), list),
                        "Expected a list")
        self.assertTrue(isinstance(data_request.get_url_list(), list),
                        "Expected a list")
        self.assertTrue(data_request.is_valid_request(),
                        "Request should be valid")
Beispiel #5
0
    def setUpClass(cls):
        super().setUpClass()

        bbox1 = BBox([-90.9216499, 14.4190528, -90.8186531, 14.5520163],
                     crs=CRS.WGS84)  # From examples
        bbox2 = BBox([46.16, -16.15, 46.51, -15.58],
                     crs=CRS.WGS84)  # From sentinelhub-py examples
        cls.custom_url_params = {
            CustomUrlParam.SHOWLOGO: True,
            CustomUrlParam.TRANSPARENT: False,
            CustomUrlParam.EVALSCRIPT: 'return [B01]',
            CustomUrlParam.ATMFILTER: 'DOS1'
        }

        cls.wms_request = WmsRequest(layer='S2-DOS1',
                                     bbox=bbox1,
                                     time=('2017-12-01', '2017-12-31'),
                                     width=60,
                                     height=None,
                                     image_format=MimeType.TIFF,
                                     custom_url_params=cls.custom_url_params,
                                     instance_id=cls.CONFIG.instance_id)
        cls.wcs_request = WcsRequest(layer='S2-ATMCOR',
                                     bbox=bbox2,
                                     time='2016-07-18T07:14:04',
                                     resx='100m',
                                     resy='100m',
                                     image_format=MimeType.PNG,
                                     data_folder='.')

        cls.test_cases = [
            TestCaseContainer('WMS',
                              CloudMaskRequest(cls.wms_request,
                                               threshold=0.6,
                                               average_over=2,
                                               dilation_size=5),
                              clm_min=0,
                              clm_max=1,
                              clm_mean=0.343827,
                              clm_median=0,
                              clp_min=0.00011,
                              clp_max=0.99999,
                              clp_mean=0.23959,
                              clp_median=0.01897,
                              mask_shape=(7, 81, 60)),
            TestCaseContainer('WCS, partial no data',
                              CloudMaskRequest(cls.wcs_request,
                                               all_bands=True),
                              clm_min=0,
                              clm_max=1,
                              clm_mean=0.04468,
                              clm_median=0,
                              clp_min=-50.0,
                              clp_max=0.999635,
                              clp_mean=-7.5472468,
                              clp_median=0.011568,
                              mask_shape=(1, 634, 374))
        ]
Beispiel #6
0
    def __init__(self,
                 bbox,
                 geometry=False,
                 end_date='latest',
                 start_date=None,
                 layer='NDVI',
                 maxcc=0.30,
                 to_nan=True,
                 last=False,
                 save_data=False,
                 eval_script=False,
                 res='10m'):
        self.bbox = bbox
        self.save_data = save_data
        self.last = last
        self.to_nan = to_nan
        custom_url_params = {constants.CustomUrlParam.TRANSPARENT: True}
        if geometry:
            custom_url_params[constants.CustomUrlParam.GEOMETRY] = geometry
        if eval_script:
            custom_url_params[
                constants.CustomUrlParam.EVALSCRIPT] = eval_script
        if start_date is not None:
            time_tuple = (start_date, end_date)
        else:
            time_tuple = end_date

        try:
            WcsRequest.__init__(self,
                                data_folder='./shub_downloads',
                                layer=layer,
                                bbox=bbox,
                                custom_url_params=custom_url_params,
                                maxcc=maxcc,
                                time=time_tuple,
                                resx=res,
                                resy=res,
                                image_format=constants.MimeType.TIFF_d32f,
                                instance_id=Config.SENTINEL_INSTANCE_ID)
        except DownloadFailedException:
            logger.error(
                'Unable to stablish connection. '
                'Please check your internet connection and try again.')
        self._run()
Beispiel #7
0
def get_S2_request(layer, dam_bbox, date, resx, resy, maxcc):
    return WcsRequest(data_folder=None,
                      layer=layer,
                      bbox=dam_bbox, 
                      time=date.strftime('%Y-%m-%d') if isinstance(date, datetime) else date, 
                      resx=f'{resx}m', resy=f'{resy}m',
                      image_format=MimeType.TIFF_d32f,
                      maxcc=maxcc,
                      time_difference=timedelta(hours=2),
                      custom_url_params={CustomUrlParam.SHOWLOGO: False})
Beispiel #8
0
 def _get_wcs_request(self, bbox, time_interval):
     """
     Returns WCS request with given BBOX and time_interval.
     """
     return WcsRequest(layer=self.layer,
                       bbox=bbox,
                       time=time_interval,
                       resx=self.size_x, resy=self.size_y,
                       maxcc=self.maxcc,
                       image_format=self.image_format,
                       custom_url_params=self.custom_url_params,
                       time_difference=self.time_difference,
                       data_source=self.data_source,
                       instance_id=self.instance_id)
Beispiel #9
0
 def _get_wcs_request(self, bbox, time_interval, size_x, size_y, maxcc,
                      time_difference, custom_url_params):
     """
     Returns WCS request.
     """
     return WcsRequest(layer=self.data_feature,
                       bbox=bbox,
                       time=time_interval,
                       resx=size_x,
                       resy=size_y,
                       maxcc=maxcc,
                       custom_url_params=custom_url_params,
                       time_difference=time_difference,
                       image_format=self.image_format,
                       data_source=self.data_source,
                       instance_id=self.instance_id)
Beispiel #10
0
    def create_wcs_request(self, time, layer):
        """
        Create Sentinel Hub WCS (Web Coverage Service) get map request.

        Used for getting image in highest resolution - 10 metres per pixel.

        :param time: time range in format ('time_from', 'time_to')
        :param layer: layer from sentinel-hub configuration
        :return: obj WcsRequest
        """
        return WcsRequest(
            layer=layer,
            bbox=self.bounding_box,
            time=time,
            maxcc=self.config.max_cloud_percentage,
            resx="10m",
            resy="10m",
            custom_url_params=self.custom_url_params,
            instance_id=self.instance_id,
        )
Beispiel #11
0
    def test_init(self):

        bbox = BBox((8.655, 111.7, 8.688, 111.6), crs=CRS.WGS84)
        data_request = WcsRequest(data_folder=self.OUTPUT_FOLDER,
                                  bbox=bbox,
                                  layer='BANDS-S2-L1C')
        data_request.create_request(
            reset_wfs_iterator=True
        )  # This method is used by s2cloudless, don't rename it

        self.assertEqual(self.OUTPUT_FOLDER,
                         data_request.data_folder,
                         msg="Expected {}, got {}".format(
                             self.OUTPUT_FOLDER, data_request.data_folder))
        self.assertTrue(isinstance(data_request.get_filename_list(), list),
                        "Expected a list")
        self.assertTrue(isinstance(data_request.get_url_list(), list),
                        "Expected a list")
        self.assertTrue(data_request.is_valid_request(),
                        "Request should be valid")
def extract_surface_water_area_per_frame(dam_id, dam_poly, dam_bbox, date,
                                         resx, resy):
    """
    Run water detection algorithm for a single timestamp.
    """
    measurement = get_new_measurement_entry(dam_id, date,
                                            WaterDetectionSensor.S2_NDWI,
                                            S2_WATER_DETECTOR_VERSION)

    # initialise requests
    try:
        wcs_ndwi_request = WcsRequest(layer='NDWI',
                                      bbox=dam_bbox,
                                      time=date.strftime('%Y-%m-%d'),
                                      maxcc=S2_MAX_CC,
                                      resx=f'{resx}m',
                                      resy=f'{resy}m',
                                      image_format=MimeType.TIFF_d32f,
                                      time_difference=timedelta(hours=2),
                                      custom_url_params={
                                          CustomUrlParam.SHOWLOGO: False,
                                          CustomUrlParam.TRANSPARENT: True
                                      })

        cloudresx, cloudresy = get_optimal_cloud_resolution(resx, resy)
        wcs_bands_request = WcsRequest(layer='NDWI',
                                       bbox=dam_bbox,
                                       time=date.strftime('%Y-%m-%d'),
                                       maxcc=S2_MAX_CC,
                                       resx=f'{cloudresx}m',
                                       resy=f'{cloudresy}m',
                                       image_format=MimeType.TIFF_d32f,
                                       time_difference=timedelta(hours=2),
                                       custom_url_params={
                                           CustomUrlParam.EVALSCRIPT:
                                           S2_CLOUD_BANDS_SCRIPT_V3
                                       })

    except (RuntimeError, DownloadFailedException):
        set_measurement_status(measurement,
                               WaterDetectionStatus.SH_REQUEST_ERROR)
        return measurement

    # download NDWI
    try:
        ndwi = np.asarray(wcs_ndwi_request.get_data())
    except (DownloadFailedException, ImageDecodingError):
        set_measurement_status(measurement,
                               WaterDetectionStatus.SH_REQUEST_ERROR)
        return measurement

    if len(ndwi) == 0:
        set_measurement_status(measurement, WaterDetectionStatus.SH_NO_DATA)
        return measurement

    # check that image has no INVALID PIXELS
    valid_pxs_frac = np.count_nonzero(ndwi[..., 1]) / np.size(ndwi[..., 1])
    if valid_pxs_frac < S2_MIN_VALID_FRACTION:
        del ndwi
        set_measurement_status(measurement, WaterDetectionStatus.INVALID_DATA)
        return measurement

    # run cloud detection
    try:
        all_cloud_masks = CloudMaskRequest(ogc_request=wcs_bands_request,
                                           threshold=0.4)
        cloud_mask = all_cloud_masks.get_cloud_masks()
    except (DownloadFailedException, ImageDecodingError):
        set_measurement_status(measurement,
                               WaterDetectionStatus.SH_REQUEST_ERROR)
        return measurement

    if len(ndwi) == 0:
        set_measurement_status(measurement,
                               WaterDetectionStatus.SH_NO_CLOUD_DATA)
        return measurement

    # check cloud coverage
    cloud_cov = np.count_nonzero(cloud_mask) / np.size(cloud_mask)
    if cloud_cov > S2_MAX_CLOUD_COVERAGE:
        del cloud_mask, all_cloud_masks
        set_measurement_status(measurement, WaterDetectionStatus.TOO_CLOUDY)
        return measurement

    measurement.CLOUD_COVERAGE = cloud_cov
    try:
        # run water detction algorithm
        result = get_water_level_optical(date,
                                         ndwi[0, ..., 0],
                                         dam_poly,
                                         dam_bbox,
                                         simplify=True)

        set_measurement_status(measurement,
                               WaterDetectionStatus.MEASUREMENT_VALID)
        measurement.SURF_WATER_LEVEL = result['water_level']
        measurement.GEOMETRY = result['geometry'].wkt
        measurement.ALG_STATUS = result['alg_status']

        del result
    except AttributeError:
        set_measurement_status(measurement,
                               WaterDetectionStatus.INVALID_POLYGON)

    del ndwi, cloud_mask, all_cloud_masks, wcs_ndwi_request, wcs_bands_request

    return measurement
Beispiel #13
0
    def setUpClass(cls):
        super().setUpClass()

        wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84)
        wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84)
        wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84)
        wgs84_bbox_4 = BBox(bbox=(-72.0, -66.4, -71.8, -66.2), crs=CRS.WGS84)
        wgs84_bbox_byoc = BBox(bbox=(13.82387, 45.85221, 13.83313, 45.85901), crs=CRS.WGS84)
        pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0), crs=CRS.POP_WEB)
        geometry_wkt_pop_web = 'POLYGON((1292344.0 5205055.5, 1301479.5 5195920.0, 1310615.0 5205055.5, ' \
                               '1301479.5 5214191.0, 1292344.0 5205055.5))'
        geometry_wkt_wgs84 = 'POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))'
        img_width = 100
        img_height = 100
        resx = '53m'
        resy = '78m'
        expected_date = datetime.datetime.strptime('2017-10-07T11:20:58', '%Y-%m-%dT%H:%M:%S')

        cls.test_cases = [
            cls.OgcTestCase('generalWmsTest',
                            OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox,
                                       layer='BANDS-S2-L1C', maxcc=0.5, size_x=img_width, size_y=img_height,
                                       time=(datetime.date(year=2017, month=1, day=5),
                                             datetime.date(year=2017, month=12, day=16)),
                                       service_type=ServiceType.WMS, time_difference=datetime.timedelta(days=10)),
                            result_len=14, img_min=0.0, img_max=1.5964, img_mean=0.1810, img_median=0.1140, tile_num=29,
                            save_data=True, data_filter=[0, -2, 0]),
            cls.OgcTestCase('generalWcsTest',
                            OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF_d32f, bbox=wgs84_bbox,
                                       layer='BANDS-S2-L1C', maxcc=0.6, size_x=resx, size_y=resy,
                                       time=(datetime.datetime(year=2017, month=10, day=7, hour=1),
                                             datetime.datetime(year=2017, month=12, day=11)),
                                       service_type=ServiceType.WCS, time_difference=datetime.timedelta(hours=1)),
                            result_len=4, img_min=0.0002, img_max=0.5266, img_mean=0.1038, img_median=0.0948,
                            tile_num=6, date_check=expected_date, save_data=True, data_filter=[0, -1]),
            # CustomUrlParam tests:
            cls.OgcTestCase('customUrlLogoQualitySampling',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C', width=img_width, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.SHOWLOGO: True,
                                                          CustomUrlParam.QUALITY: 100,
                                                          CustomUrlParam.DOWNSAMPLING: 'BICUBIC',
                                                          CustomUrlParam.UPSAMPLING: 'BICUBIC'}),
                            result_len=1, img_min=29, img_max=255, img_mean=179.833917, img_median=181, tile_num=2,
                            data_filter=[0, -1]),
            cls.OgcTestCase('customUrlPreview',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C', height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.PREVIEW: 2}),
                            result_len=1, img_min=27, img_max=244, img_mean=175.51357, img_median=177, tile_num=2),
            cls.OgcTestCase('customUrlEvalscripturl',
                            WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=pop_web_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.EVALSCRIPTURL:
                                                              'https://raw.githubusercontent.com/sentinel-hub/'
                                                              'customScripts/master/sentinel-2/false_color_infrared/'
                                                              'script.js'}),
                            result_len=1, img_min=46, img_max=255, img_mean=231.051154, img_median=255, tile_num=3),
            cls.OgcTestCase('customUrlEvalscript,Transparent,Geometry',
                            WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.TRANSPARENT: True,
                                                          CustomUrlParam.EVALSCRIPT: 'return [B10,B8A, B03 ]',
                                                          CustomUrlParam.GEOMETRY: geometry_wkt_wgs84}),
                            result_len=1, img_min=0, img_max=255, img_mean=50.726361, img_median=1.0, tile_num=2),
            cls.OgcTestCase('FalseLogo,BgColor,Geometry',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C', width=img_width, height=img_height, bbox=pop_web_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.SHOWLOGO: False,
                                                          CustomUrlParam.BGCOLOR: "F4F86A",
                                                          CustomUrlParam.GEOMETRY: geometry_wkt_pop_web}),
                            result_len=1, img_min=64, img_max=MimeType.PNG.get_expected_max_value(), img_mean=213.6124,
                            img_median=242.0, tile_num=3),
            # DataSource tests:
            cls.OgcTestCase('S2 L1C Test',
                            WmsRequest(data_source=DataSource.SENTINEL2_L1C, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d8, layer='BANDS-S2-L1C',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02')),
                            result_len=1, img_min=0, img_max=160, img_mean=60.50514, img_median=63.0,
                            tile_num=2),
            cls.OgcTestCase('S2 L2A Test',
                            WmsRequest(data_source=DataSource.SENTINEL2_L2A, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S2-L2A',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02')),
                            result_len=1, img_min=0.0, img_max=MimeType.TIFF.get_expected_max_value(),
                            img_mean=22744.01498, img_median=21391.0, tile_num=2),
            cls.OgcTestCase('L8 Test',
                            WmsRequest(data_source=DataSource.LANDSAT8, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-L8',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-05', '2017-10-10'), time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0012, img_max=285.78003, img_mean=52.06088, img_median=0.5192,
                            tile_num=2),
            cls.OgcTestCase('DEM Test',
                            WmsRequest(data_source=DataSource.DEM, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='DEM',
                                       width=img_width, height=img_height, bbox=wgs84_bbox),
                            result_len=1, img_min=-108.0, img_max=-18.0, img_mean=-72.2097, img_median=-72.0),
            cls.OgcTestCase('MODIS Test',
                            WmsRequest(data_source=DataSource.MODIS, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-MODIS',
                                       width=img_width, height=img_height, bbox=wgs84_bbox, time='2017-10-01'),
                            result_len=1, img_min=0.0, img_max=3.2767, img_mean=0.136548, img_median=0.00240,
                            tile_num=1),
            cls.OgcTestCase('S1 IW Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.00150, img_max=MimeType.TIFF_d32f.get_expected_max_value(),
                            img_mean=0.1135815, img_median=0.06210, tile_num=2),
            cls.OgcTestCase('S1 EW Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_EW, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_2,
                                       time=('2018-2-7', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=2, img_min=0.0003, img_max=1.0, img_mean=0.53118, img_median=1.0, tile_num=3),
            cls.OgcTestCase('S1 EW SH Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_EW_SH,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_3,
                                       time=('2018-2-6', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=472, img_max=3538, img_mean=926.8818, img_median=894.0,
                            tile_num=1),
            cls.OgcTestCase('S1 IW ASC Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_IW_ASC, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-03'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.00150, img_max=MimeType.TIFF_d32f.get_expected_max_value(),
                            img_mean=0.1135815, img_median=0.0621000, tile_num=2),
            cls.OgcTestCase('S1 EW ASC Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_EW_ASC, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_2,
                                       time=('2018-2-7', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0003, img_max=0.2322, img_mean=0.02199, img_median=0.0102,
                            tile_num=2),
            cls.OgcTestCase('S1 EW SH ASC Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_EW_SH_ASC,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_3,
                                       time=('2018-2-6', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=472, img_max=3538, img_mean=926.8818, img_median=894.0,
                            tile_num=1),
            cls.OgcTestCase('S1 IW DES Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_IW_DES, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-S1-IW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-05'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0, img_max=0.07700,
                            img_mean=0.0210801, img_median=0.0132, tile_num=1),
            cls.OgcTestCase('S1 EW DES Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_EW_DES, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS-S1-EW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_2,
                                       time=('2018-2-7', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0003, img_max=1.0, img_mean=0.53118, img_median=1.0, tile_num=1),
            cls.OgcTestCase('S1 EW SH DES Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_EW_SH_DES,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d16, layer='BANDS-S1-EW-SH',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_4,
                                       time=('2018-2-5', '2018-2-6'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=3975, img_max=37973, img_mean=15061.2035, img_median=14769.0,
                            tile_num=1),
            # cls.OgcTestCase('BYOC Test',
            #                 WmsRequest(data_source=DataSource('31df1de4-8bd4-43e0-8c3f-b04262d111b6'),
            #                            data_folder=cls.OUTPUT_FOLDER,
            #                            image_format=MimeType.TIFF_d16, layer='DEMO_BYOC_LAYER',
            #                            width=img_width, height=img_height, bbox=wgs84_bbox_byoc,
            #                            custom_url_params={CustomUrlParam.SHOWLOGO: False}),
            #                 result_len=1, img_min=0, img_max=65535, img_mean=17158.8938, img_median=15728.0,
            #                 tile_num=1)
        ]
        """
        # Test case for eocloud data source
        cls.test_cases.extend([
            cls.OgcTestCase('EOCloud S1 IW Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS_S1_IW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0, img_max=0.49706, img_mean=0.04082, img_median=0.00607,
                            tile_num=2),
        ])
        """

        for test_case in cls.test_cases:
            test_case.collect_data()
Beispiel #14
0
        d = dates[i]
        if (last_date is not None):
            if ((last_date - d).total_seconds() < 3600):
                continue

        last_date = d
        add_data = additional_data[i]
        filepath = join(
            to_images_path,
            d.strftime("%Y%m%d_%H%M%S") + '_' + '_'.join(add_data) + '.tif')
        if (isfile(filepath)):
            continue
        print(d)
        s1_request = WcsRequest(
            data_source=DataSource.SENTINEL1_IW,
            layer='BOTH',
            bbox=search_bbox,
            time=d,
            resx=args.resolution,
            resy=args.resolution,
            image_format=constants.MimeType.TIFF_d32f,  #_d32f
            instance_id=INSTANCE_ID)

        s1_data = s1_request.get_data()
        tifffile.imsave(filepath,
                        np.dstack((s1_data[-1],
                                   np.zeros((s1_data[-1].shape[0],
                                             s1_data[-1].shape[1])))),
                        compress=7)

    #sys.exit()
Beispiel #15
0
for p in range(0, len(intervals)):
    t = intervals[p]
    save_dir = path_dir + '\\' + site_name + '\\' + t
    if os.path.isdir(save_dir) == False:
        os.mkdir(save_dir)
    if t == 'pre-fire':
        t_start = pre_start
        t_end = pre_end
    else:
        t_start = post_start
        t_end = post_end
    wms_pre = WcsRequest(data_folder=save_dir,
                         layer='VSPI',
                         bbox=bbox_1,
                         time=(t_start, t_end),
                         resx='60m',
                         resy='60m',
                         image_format=MimeType.TIFF,
                         maxcc=cloud_cover,
                         instance_id=i_id)

    print('Downloading ' + t + ' data.....')
    wms_pre.save_data()

#save BA bands
for p in range(0, len(intervals)):
    t = intervals[p]
    ba_save_dir = path_dir + '\\' + site_name + '\\ba\\'
    if os.path.isdir(ba_save_dir) == False:
        os.mkdir(ba_save_dir)
    if os.path.isdir(ba_save_dir + t) == False:
Beispiel #16
0
    data_folder='.')
wms_true_color_request = WmsRequest(
    data_collection=DataCollection.SENTINEL2_L1C,
    layer='NDVI',
    bbox=the_dam_bbox,
    time='2019-06-20',
    width=512,
    height=856,
    maxcc=0.5,
    image_format=MimeType.TIFF_d32f,
    config=config,
    data_folder='.')

wcs_ndwi_request = WcsRequest(
    data_collection=DataCollection.SENTINEL2_L1C,
    layer='NDWI',
    bbox=the_dam_bbox,
    time='latest',
    maxcc=0.5,
    resx='20m',
    resy='20m',
    image_format=MimeType.TIFF_d32f,
    # time_difference=timedelta(hours=2),
    # custom_url_params={CustomUrlParam.SHOWLOGO: False,
    #                    CustomUrlParam.TRANSPARENT: True},
    config=config,
    data_folder='.')

wms_true_color_img = wcs_ndwi_request.get_data(save_data=True)
wms_true_color_img = wms_true_color_request.get_data(save_data=True)
Beispiel #17
0
                     channel_df['mean'] - channel_df['stDev'],
                     channel_df['mean'] + channel_df['stDev'],
                     alpha=0.2,
                     color=color)

plt.legend(loc='upper right')
"""
As there is no vegetation in the desert the reflectance values shouldn't change much over time. 
...(read details in tutorial doc)...
We can conclude the 5th,9th,14th acquisition contains clouds while 10th acquisition contains the sandstorm.
Let's download the true color images for these acquisitions and visually verify the results.
"""
wcs_request = WcsRequest(data_collection=DataCollection.SENTINEL2_L1C,
                         layer='TRUE-COLOR-S2-L1C',
                         bbox=sahara_bbox,
                         time=time_interval,
                         resx='60m',
                         resy='60m',
                         custom_url_params={CustomUrlParam.SHOWLOGO: False},
                         config=config)

images = wcs_request.get_data()

fig, axs = plt.subplots((len(images) + 2) // 3, 3, figsize=(8, 16))
for idx, (image, time) in enumerate(zip(images, wcs_request.get_dates())):
    axs.flat[idx].imshow(image)
    axs.flat[idx].set_title(time.date().isoformat())
fig.tight_layout()
"""
Comparing Histograms: FIS can also provide histograms of calues split into a specified number of binds which will allows
us to analyse the distribution of values without having to download entire images.
Beispiel #18
0
    def setUpClass(cls):
        wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84)
        wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84)
        wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84)
        pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0),
                            crs=CRS.POP_WEB)
        geometry_wkt_pop_web = 'POLYGON((1292344.0 5205055.5, 1301479.5 5195920.0, 1310615.0 5205055.5, ' \
                               '1301479.5 5214191.0, 1292344.0 5205055.5))'
        geometry_wkt_wgs84 = 'POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))'
        img_width = 100
        img_height = 100
        resx = '53m'
        resy = '78m'
        expected_date = datetime.datetime.strptime('2017-10-07T11:20:58',
                                                   '%Y-%m-%dT%H:%M:%S')

        cls.test_cases = [
            cls.OgcTestCase('generalWmsTest',
                            OgcRequest(
                                data_folder=cls.OUTPUT_FOLDER,
                                image_format=MimeType.TIFF_d32f,
                                bbox=wgs84_bbox,
                                layer='BANDS-S2-L1C',
                                maxcc=0.5,
                                size_x=img_width,
                                size_y=img_height,
                                time=(datetime.date(year=2017, month=1, day=5),
                                      datetime.date(year=2017,
                                                    month=12,
                                                    day=16)),
                                service_type=ServiceType.WMS,
                                time_difference=datetime.timedelta(days=10)),
                            result_len=14,
                            img_min=0.0,
                            img_max=1.5964,
                            img_mean=0.1810,
                            img_median=0.1140,
                            tile_num=29,
                            save_data=True,
                            data_filter=[0, -2, 0]),
            cls.OgcTestCase('generalWcsTest',
                            OgcRequest(
                                data_folder=cls.OUTPUT_FOLDER,
                                image_format=MimeType.TIFF_d32f,
                                bbox=wgs84_bbox,
                                layer='BANDS-S2-L1C',
                                maxcc=0.6,
                                size_x=resx,
                                size_y=resy,
                                time=(datetime.datetime(year=2017,
                                                        month=10,
                                                        day=7,
                                                        hour=1),
                                      datetime.datetime(year=2017,
                                                        month=12,
                                                        day=11)),
                                service_type=ServiceType.WCS,
                                time_difference=datetime.timedelta(hours=1)),
                            result_len=4,
                            img_min=0.0002,
                            img_max=0.5266,
                            img_mean=0.1038,
                            img_median=0.0948,
                            tile_num=6,
                            date_check=expected_date,
                            save_data=True,
                            data_filter=[0, -1]),
            # CustomUrlParam tests:
            cls.OgcTestCase('customUrlAtmcorQualitySampling',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C',
                                       width=img_width,
                                       bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={
                                           CustomUrlParam.SHOWLOGO: True,
                                           CustomUrlParam.ATMFILTER: 'ATMCOR',
                                           CustomUrlParam.QUALITY: 100,
                                           CustomUrlParam.DOWNSAMPLING:
                                           'BICUBIC',
                                           CustomUrlParam.UPSAMPLING: 'BICUBIC'
                                       }),
                            result_len=1,
                            img_min=11,
                            img_max=255,
                            img_mean=193.796,
                            img_median=206,
                            tile_num=2,
                            data_filter=[0, -1]),
            cls.OgcTestCase('customUrlPreview',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C',
                                       height=img_height,
                                       bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={
                                           CustomUrlParam.SHOWLOGO: True,
                                           CustomUrlParam.PREVIEW: 2
                                       }),
                            result_len=1,
                            img_min=27,
                            img_max=253,
                            img_mean=176.732,
                            img_median=177,
                            tile_num=2),
            cls.OgcTestCase(
                'customUrlEvalscripturl',
                WcsRequest(
                    data_folder=cls.OUTPUT_FOLDER,
                    image_format=MimeType.PNG,
                    layer='TRUE-COLOR-S2-L1C',
                    resx=resx,
                    resy=resy,
                    bbox=pop_web_bbox,
                    time=('2017-10-01', '2017-10-02'),
                    custom_url_params={
                        CustomUrlParam.SHOWLOGO:
                        True,
                        CustomUrlParam.EVALSCRIPTURL:
                        'https://raw.githubusercontent.com/sentinel-hub/'
                        'customScripts/master/sentinel-2/false_color_infrared/'
                        'script.js'
                    }),
                result_len=1,
                img_min=41,
                img_max=255,
                img_mean=230.568,
                img_median=255,
                tile_num=3),
            cls.OgcTestCase('customUrlEvalscript,Transparent,Geometry',
                            WcsRequest(data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C',
                                       resx=resx,
                                       resy=resy,
                                       bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={
                                           CustomUrlParam.SHOWLOGO:
                                           True,
                                           CustomUrlParam.TRANSPARENT:
                                           True,
                                           CustomUrlParam.EVALSCRIPT:
                                           'return [B10,B8A, B03 ]',
                                           CustomUrlParam.GEOMETRY:
                                           geometry_wkt_wgs84
                                       }),
                            result_len=1,
                            img_min=0,
                            img_max=255,
                            img_mean=53.71428,
                            img_median=1.0,
                            tile_num=2),
            cls.OgcTestCase('FalseLogo,BgColor,Geometry',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.PNG,
                                       layer='TRUE-COLOR-S2-L1C',
                                       width=img_width,
                                       height=img_height,
                                       bbox=pop_web_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={
                                           CustomUrlParam.SHOWLOGO:
                                           False,
                                           CustomUrlParam.BGCOLOR:
                                           "F4F86A",
                                           CustomUrlParam.GEOMETRY:
                                           geometry_wkt_pop_web
                                       }),
                            result_len=1,
                            img_min=63,
                            img_max=255,
                            img_mean=213.3590,
                            img_median=242.0,
                            tile_num=3),
            # DataSource tests:
            cls.OgcTestCase('S2 L1C Test',
                            WmsRequest(data_source=DataSource.SENTINEL2_L1C,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d8,
                                       layer='BANDS-S2-L1C',
                                       width=img_width,
                                       height=img_height,
                                       bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02')),
                            result_len=1,
                            img_min=0,
                            img_max=160,
                            img_mean=59.9996,
                            img_median=63.0,
                            tile_num=2),
            cls.OgcTestCase('S2 L2A Test',
                            WmsRequest(data_source=DataSource.SENTINEL2_L2A,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF,
                                       layer='BANDS-S2-L2A',
                                       width=img_width,
                                       height=img_height,
                                       bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02')),
                            result_len=1,
                            img_min=0.0,
                            img_max=65535,
                            img_mean=22743.5164,
                            img_median=21390.0,
                            tile_num=2),
            cls.OgcTestCase('L8 Test',
                            WmsRequest(
                                data_source=DataSource.LANDSAT8,
                                data_folder=cls.OUTPUT_FOLDER,
                                image_format=MimeType.TIFF_d32f,
                                layer='BANDS-L8',
                                width=img_width,
                                height=img_height,
                                bbox=wgs84_bbox,
                                time=('2017-10-05', '2017-10-10'),
                                time_difference=datetime.timedelta(hours=1)),
                            result_len=1,
                            img_min=0.0011,
                            img_max=285.72415,
                            img_mean=52.06075,
                            img_median=0.5192,
                            tile_num=2),
            cls.OgcTestCase('DEM Test',
                            WmsRequest(data_source=DataSource.DEM,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f,
                                       layer='DEM',
                                       width=img_width,
                                       height=img_height,
                                       bbox=wgs84_bbox),
                            result_len=1,
                            img_min=-108.0,
                            img_max=-18.0,
                            img_mean=-72.1819,
                            img_median=-72.0),
            cls.OgcTestCase('MODIS Test',
                            WmsRequest(data_source=DataSource.MODIS,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f,
                                       layer='BANDS-MODIS',
                                       width=img_width,
                                       height=img_height,
                                       bbox=wgs84_bbox,
                                       time='2017-10-01'),
                            result_len=1,
                            img_min=0.0,
                            img_max=3.2767,
                            img_mean=0.136408,
                            img_median=0.00240,
                            tile_num=1),
            cls.OgcTestCase('S1 IW Test',
                            WmsRequest(
                                data_source=DataSource.SENTINEL1_IW,
                                data_folder=cls.OUTPUT_FOLDER,
                                image_format=MimeType.TIFF_d32f,
                                layer='BANDS-S1-IW',
                                width=img_width,
                                height=img_height,
                                bbox=wgs84_bbox,
                                time=('2017-10-01', '2017-10-02'),
                                time_difference=datetime.timedelta(hours=1)),
                            result_len=1,
                            img_min=0.0,
                            img_max=1.0,
                            img_mean=0.104584,
                            img_median=0.06160,
                            tile_num=2),
            cls.OgcTestCase('S1 EW Test',
                            WmsRequest(
                                data_source=DataSource.SENTINEL1_EW,
                                data_folder=cls.OUTPUT_FOLDER,
                                image_format=MimeType.TIFF_d32f,
                                layer='BANDS-S1-EW',
                                width=img_width,
                                height=img_height,
                                bbox=wgs84_bbox_2,
                                time=('2018-2-7', '2018-2-8'),
                                time_difference=datetime.timedelta(hours=1)),
                            result_len=2,
                            img_min=0.0003,
                            img_max=1.0,
                            img_mean=0.53118,
                            img_median=1.0,
                            tile_num=3),
            cls.OgcTestCase(
                'S1 EW SH Test',
                WmsRequest(data_source=DataSource.SENTINEL1_EW_SH,
                           data_folder=cls.OUTPUT_FOLDER,
                           image_format=MimeType.TIFF_d16,
                           layer='BANDS-S1-EW-SH',
                           width=img_width,
                           height=img_height,
                           bbox=wgs84_bbox_3,
                           custom_url_params={CustomUrlParam.SHOWLOGO: True},
                           time=('2018-2-6', '2018-2-8'),
                           time_difference=datetime.timedelta(hours=1)),
                result_len=1,
                img_min=465,
                img_max=59287,
                img_mean=5323.0523,
                img_median=943.0,
                tile_num=1)
        ]
        """
        # Test case for eocloud data source
        cls.test_cases.extend([
            cls.OgcTestCase('EOCloud S1 IW Test',
                            WmsRequest(data_source=DataSource.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF_d32f, layer='BANDS_S1_IW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0, img_max=0.49706, img_mean=0.04082, img_median=0.00607,
                            tile_num=2),
        ])
        """

        for test_case in cls.test_cases:
            test_case.collect_data()
Beispiel #19
0
    def setUpClass(cls):
        super().setUpClass()

        wgs84_bbox = BBox(bbox=(-5.23, 48.0, -5.03, 48.17), crs=CRS.WGS84)
        wgs84_bbox_2 = BBox(bbox=(21.3, 64.0, 22.0, 64.5), crs=CRS.WGS84)
        wgs84_bbox_3 = BBox(bbox=(-72.0, -70.4, -71.8, -70.2), crs=CRS.WGS84)
        wgs84_bbox_4 = BBox(bbox=(-72.0, -66.4, -71.8, -66.2), crs=CRS.WGS84)
        pop_web_bbox = BBox(bbox=(1292344.0, 5195920.0, 1310615.0, 5214191.0), crs=CRS.POP_WEB)
        geometry_wkt_pop_web = 'POLYGON((1292344.0 5205055.5, 1301479.5 5195920.0, 1310615.0 5205055.5, ' \
                               '1301479.5 5214191.0, 1292344.0 5205055.5))'
        geometry_wkt_wgs84 = 'POLYGON((-5.13 48, -5.23 48.09, -5.13 48.17, -5.03 48.08, -5.13 48))'
        img_width = 100
        img_height = 100
        resx = '53m'
        resy = '78m'
        expected_date = datetime.datetime.strptime('2017-10-07T11:20:58', '%Y-%m-%dT%H:%M:%S')

        cls.test_cases = [
            cls.OgcTestCase('generalWmsTest',
                            OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, bbox=wgs84_bbox,
                                       data_collection=DataCollection.SENTINEL2_L1C,
                                       layer='BANDS-S2-L1C', maxcc=0.5, size_x=img_width, size_y=img_height,
                                       time=(datetime.date(year=2017, month=1, day=5),
                                             datetime.date(year=2017, month=12, day=16)),
                                       service_type=ServiceType.WMS, time_difference=datetime.timedelta(days=10)),
                            result_len=14, img_min=0.0, img_max=1.5964, img_mean=0.2395, img_median=0.1349, tile_num=29,
                            save_data=True, data_filter=[0, -2, 0]),
            cls.OgcTestCase('generalWcsTest',
                            OgcRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.TIFF, bbox=wgs84_bbox,
                                       data_collection=DataCollection.SENTINEL2_L1C,
                                       layer='BANDS-S2-L1C', maxcc=0.6, size_x=resx, size_y=resy,
                                       time=(datetime.datetime(year=2017, month=10, day=7, hour=1),
                                             datetime.datetime(year=2017, month=12, day=11)),
                                       service_type=ServiceType.WCS, time_difference=datetime.timedelta(hours=1)),
                            result_len=4, img_min=0.0002, img_max=1.0, img_mean=0.16779, img_median=0.1023,
                            tile_num=6, date_check=expected_date, save_data=True, data_filter=[0, -1]),
            # CustomUrlParam tests:
            cls.OgcTestCase('customUrlLogoQualitySampling',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       data_collection=DataCollection.SENTINEL2_L1C,
                                       layer='TRUE-COLOR-S2-L1C', width=img_width, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.SHOWLOGO: True,
                                                          CustomUrlParam.QUALITY: 100,
                                                          CustomUrlParam.DOWNSAMPLING: 'BICUBIC',
                                                          CustomUrlParam.UPSAMPLING: 'BICUBIC'}),
                            result_len=1, img_min=29, img_max=255, img_mean=198.6254375, img_median=206, tile_num=2,
                            data_filter=[0, -1]),
            cls.OgcTestCase('customUrlPreview',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       data_collection=DataCollection.SENTINEL2_L1C,
                                       layer='TRUE-COLOR-S2-L1C', height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.PREVIEW: 2}),
                            result_len=1, img_min=27, img_max=255, img_mean=195.385181, img_median=199, tile_num=2),
            cls.OgcTestCase('customUrlEvalscripturl',
                            WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       data_collection=DataCollection.SENTINEL2_L1C,
                                       layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=pop_web_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.EVALSCRIPTURL:
                                                              'https://raw.githubusercontent.com/sentinel-hub/'
                                                              'customScripts/master/sentinel-2/false_color_infrared/'
                                                              'script.js'}),
                            result_len=1, img_min=46, img_max=255, img_mean=231.051154, img_median=255, tile_num=3),
            cls.OgcTestCase('customUrlEvalscript,Geometry',
                            WcsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       data_collection=DataCollection.SENTINEL2_L1C,
                                       layer='TRUE-COLOR-S2-L1C', resx=resx, resy=resy, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.EVALSCRIPT: 'return [B10, B8A, B03]',
                                                          CustomUrlParam.GEOMETRY: geometry_wkt_wgs84}),
                            result_len=1, img_min=0, img_max=152, img_mean=24.5405, img_median=1.0, tile_num=2),
            cls.OgcTestCase('FalseLogo,Geometry',
                            WmsRequest(data_folder=cls.OUTPUT_FOLDER, image_format=MimeType.PNG,
                                       data_collection=DataCollection.SENTINEL2_L1C,
                                       layer='TRUE-COLOR-S2-L1C', width=img_width, height=img_height, bbox=pop_web_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       custom_url_params={CustomUrlParam.SHOWLOGO: False,
                                                          CustomUrlParam.GEOMETRY: geometry_wkt_pop_web}),
                            result_len=1, img_min=0, img_max=MimeType.PNG.get_expected_max_value(), img_mean=119.4666,
                            img_median=123, tile_num=3),
            # DataCollection tests:
            cls.OgcTestCase('S2 L1C Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL2_L1C, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S2-L1C',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02')),
                            result_len=1, img_min=0.0009, img_max=1.0, img_mean=0.2917, img_median=0.2572,
                            tile_num=2),
            cls.OgcTestCase('S2 L2A Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL2_L2A, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S2-L2A',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02')),
                            result_len=1, img_min=0.0, img_max=1.6720, img_mean=0.39766, img_median=0.3393, tile_num=2),
            cls.OgcTestCase('L8 Test',
                            WmsRequest(data_collection=DataCollection.LANDSAT8, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-L8',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-05', '2017-10-10'), time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0011, img_max=285.72681, img_mean=47.80554, img_median=0.53305,
                            tile_num=2),
            cls.OgcTestCase('DEM Test',
                            WmsRequest(data_collection=DataCollection.DEM, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='DEM',
                                       width=img_width, height=img_height, bbox=wgs84_bbox),
                            result_len=1, img_min=-108.0, img_max=1, img_mean=-35.6049, img_median=-8.5),
            cls.OgcTestCase('MODIS Test',
                            WmsRequest(data_collection=DataCollection.MODIS, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-MODIS',
                                       width=img_width, height=img_height, bbox=wgs84_bbox, time='2017-10-01'),
                            result_len=1, img_min=0.0, img_max=3.2767, img_mean=0.2445, img_median=0.0030, tile_num=1),
            cls.OgcTestCase('S1 IW Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL1_IW, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S1-IW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-02'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0, img_max=1.0, img_mean=0.3508, img_median=0.07607, tile_num=2),
            cls.OgcTestCase('S1 EW Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL1_EW, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S1-EW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_2,
                                       time=('2018-2-7', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=2, img_min=0.0, img_max=1.0, img_mean=0.24709, img_median=0.00322, tile_num=3),
            cls.OgcTestCase('S1 EW SH Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL1_EW_SH,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S1-EW-SH',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_3,
                                       time=('2018-2-6', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.00697, img_max=1.0, img_mean=0.5071, img_median=0.5276, tile_num=1),
            cls.OgcTestCase('S1 EW ASC Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL1_EW_ASC, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S1-EW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_2,
                                       time=('2018-2-7', '2018-2-8'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0, img_max=1.0, img_mean=0.34803, img_median=0.02383,
                            tile_num=2),
            cls.OgcTestCase('S1 IW DES Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL1_IW_DES, data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='BANDS-S1-IW',
                                       width=img_width, height=img_height, bbox=wgs84_bbox,
                                       time=('2017-10-01', '2017-10-05'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=1, img_min=0.0, img_max=1.0, img_mean=0.3474, img_median=0.04069, tile_num=1),
            cls.OgcTestCase('S3 OLCI Test',
                            WmsRequest(data_collection=DataCollection.SENTINEL3_OLCI,
                                       data_folder=cls.OUTPUT_FOLDER,
                                       image_format=MimeType.TIFF, layer='TRUE-COLOR-S3-OLCI',
                                       width=img_width, height=img_height, bbox=wgs84_bbox_4,
                                       time=('2020-2-5', '2020-2-10'),
                                       time_difference=datetime.timedelta(hours=1)),
                            result_len=11, img_min=243, img_max=255, img_mean=248.80765, img_median=248.0, tile_num=17),
        ]

        for test_case in cls.test_cases:
            test_case.collect_data()