Global surface water

I would like to download the Global Surface Water product (https://collections.sentinel-hub.com/global-surface-water/) to mask Sentinel 3 data over rivers. But I couldn’t find it in the datacollection

from sentinelhub import DataCollection

Is there another way to access the data with the API?

Hi @paolo.filippucci ,

Yes, you can access the data with the API. Here is an example notebook we prepared to demonstrate how to access Sentinel Hub Public Collections.

Hope this would help!

I read the example and I wrote a code to extract the mask i need. However I received an error.

DownloadFailedException: Failed to download from:
https://services.sentinel-hub.com/api/v1/process
with HTTPError:
400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/process
Server response: "{"status": 400, "reason": "Bad Request", "message": "Requesting only remote collections is not allowed. At least one requested collection must be hosted by the API endpoint. Please use one of the following endpoints with your request: creodias.sentinel-hub.com.", "code": "RENDERER_EXCEPTION"}"

This is acttualy ok for me since I would like to download these data together with the data of Sentinel-3 in the same area (and potentially with the same grid).
Is it possible? Do you have any suggestions?

This is my code for now.

    roi_bbox = BBox(bbox=[10.6803682, 44.9699252, 10.830368199999999, 45.119925200000004], crs=CRS.WGS84)
    roi_bbox_size = bbox_to_dimensions(roi_bbox, resolution=300)
    time_interval = (str(2016)+'-10-01T00:00:00.000000000', str(2023)+'-09-30T23:59:59.000000000')

    # Get Water mask data

    WaterMask = DataCollection.define_byoc(
                    collection_id="9a525f12-33b6-424e-a0f2-d567eec0f277"
                    )
    WaterMask_fun = """
                        //VERSION=3
                        function setup() {
                          return {
                            input: [{
                                bands: ["extent"]
                                }],
                            output: {
                                bands: 1,
                                sampleType: SampleType.UINT8
                            },
                          };
                        }
                        
                        function evaluatePixel(sample) {
                          return [sample.extent];
                        }
                        """
                        
    request_WaterMask = SentinelHubRequest(
                       evalscript=WaterMask_fun,
                       input_data=[
                           SentinelHubRequest.input_data(
                               data_collection=WaterMask, time_interval=time_interval)
                       ],
                       responses=[
                           SentinelHubRequest.output_response(
                               "default", MimeType.TIFF)
                       ],
                       bbox=roi_bbox,
                       size=roi_bbox_size,
                   )    
            
    WaterMask = request_WaterMask.get_data()
                        
    # Get S3 data
    class AddValidDataMaskTask(EOTask):
                def execute(self, eopatch):
                    eopatch.mask["VALID_DATA"] =  ~(eopatch.mask["CLOUD_MASK"])
                    return eopatch


    indices_evalscript = """
                                    //VERSION=3
                                
                                    function setup() {
                                        return {
                                            input: ["B17", "B08", "QUALITY_FLAGS"],
                                            output:[{
                                                id: "BANDS",
                                                bands: 2,
                                                sampleType: SampleType.FLOAT32
                                            },
                                            {
                                                id: "CLOUD_MASK",
                                                bands: 1,
                                                sampleType: SampleType.UINT8
                                            }]
                                        }
                                    }
                                
    function evaluatePixel(sample) {
                                        let cld = (sample.QUALITY_FLAGS & 134217728);
                                        return {
                                           CLOUD_MASK: [cld],
                                           BANDS: [sample.B17, sample.B08]
                                        };
                                    }
                                """

    add_indices = SentinelHubEvalscriptTask(
                features=[(FeatureType.DATA, "BANDS"),
                          (FeatureType.MASK, "CLOUD_MASK")],
                evalscript=indices_evalscript,
                data_collection=DataCollection.SENTINEL3_OLCI,
                resolution=300
            )


Hi @paolo.filippucci ,

According to the error message, you seems to use the incorrect endpoint. The endpoint of the Global Surface Water collection is creodias.sentinel-hub.com. You need to set the config.sh_base_url as "https://creodias.sentinel-hub.com" like the Example 3: Corine Land Cover Data of the example notebook I provided earlier.

Thank you, now it works!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.