Skip to main content

Hi,


I want to use your s2cloudless-cloudmask and used the following code for that:


outdir = "PATH_TO_MY_OUTPUT_FOLDER"
bbox = [16.53,47.83,16.84,48.31]
BBOX = BBox(bbox=bbox, crs=CRS.WGS84)
Layer = 'NDVI'
start = '2018-04-10'
end = '2018-04-20'
res = 20
bands_script = 'return [B01,B02,B04,B05,B08,B8A,B09,B10,B1972,B12];'

wcs2 = WcsRequest(data_folder=outdir,
layer=Layer,
bbox=BBOX,
time=(start, end),
resx='{}m'.format(res), resy='{}m'.format(res),
image_format=MimeType.TIFF_d32f,
instance_id=INSTANCE_ID,
custom_url_params={CustomUrlParam.EVALSCRIPT: bands_script})

wcs_bands = wcs2.get_data()

cloud_detector = S2PixelCloudDetector(threshold=threshold, average_over=average_over, dilation_size=dilation_size) # all_bands is not defined -> Default
cloud_probs = cloud_detector.get_cloud_probability_maps(np.array(wcs_bands))
cloud_masks = cloud_detector.get_cloud_masks(np.array(wcs_bands))

However, I get the following error message:


Traceback (most recent call last):
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\site-packages\sentinelhub\download.py", line 223, in execute_download_request
response.raise_for_status()
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\site-packages\requests\models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://services.sentinel-hub.com /ogc/wcs/ded359c3-31a5-1aea-cd1b-XXX?SERVICE=wcs&BBOX=47.83%2C16.53%2C48.31%2C16.84&FORMAT=image%2Ftiff%3Bdepth%3D32f&CRS=EPSG%3A4326&RESX=20m&RESY=20m&COVERAGE=NDVI&REQUEST=GetCoverage&TIME=2018-05-13T09%3A57%3A05%2F2018-05-13T09%3A57%3A05&MAXCC=100.0&EvalScript=cmV0dXJuIFtCMDEsQjAyLEIwNCxCMDUsQjA4LEI4QSxCMDksQjEwLEIxMSxCMTJdOw%3D%3D

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/schmid/Desktop/SchmidJohannes/CropMonFolder/Sinergise/SentinelHub_finalVersion.py", line 155, in <module>
cloud_probs, cloud_masks = Sinergise_Cloudmask(sub_bbox)
File "C:/Users/schmid/Desktop/SchmidJohannes/CropMonFolder/Sinergise/SentinelHub_finalVersion.py", line 86, in Sinergise_Cloudmask
wcs_bands = wcs2.get_data()
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\site-packages\sentinelhub\data_request.py", line 87, in get_data
data_list = self._execute_data_download(redownload, max_threads)
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\site-packages\sentinelhub\data_request.py", line 119, in _execute_data_download
data_list.append(future.result(timeout=SHConfig().download_timeout_seconds))
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\concurrent\futures\_base.py", line 398, in result
return self.__get_result()
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\concurrent\futures\_base.py", line 357, in __get_result
raise self._exception
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\concurrent\futures\thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\schmid\AppData\Local\Continuum\Anaconda2\envs\cobra\lib\site-packages\sentinelhub\download.py", line 239, in execute_download_request
raise DownloadFailedException(_create_download_failed_message(exception))
sentinelhub.download.DownloadFailedException: Failed to download with HTTPError:
400 Client Error: Bad Request for url: https://services.sentinel-hub.com/ogc/wcs/ded359c3-31a5-1aea-cd1b-XXX?SERVICE=wcs&BBOX=47.83%2C16.53%2C48.31%2C16.84&FORMAT=image%2Ftiff%3Bdepth%3D32f&CRS=EPSG%3A4326&RESX=20m&RESY=20m&COVERAGE=NDVI&REQUEST=GetCoverage&TIME=2018-05-13T09%3A57%3A05%2F2018-05-13T09%3A57%3A05&MAXCC=100.0&EvalScript=cmV0dXJuIFtCMDEsQjAyLEIwNCxCMDUsQjA4LEI4QSxCMDksQjEwLEIxMSxCMTJdOw%3D%3D
Server response: "Failed to evaluate script!
ReferenceError: B10 is not defined"

Process finished with exit code 1

It seems like band 10 was not found. Have you ever experienced that error or do I need to use the WMS instead of the WCS service?

Might it be that you are using L2A datasource instead of L1C? Atmospherically corrected data do not have B10 anymore.

Wms and wcs have no difference in which data is available


I thought I tried both data sources.

Do I need to set data_source=DataSource.SENTINEL2_L1C and use an L1C layer at the same time?


Parameter data_source is by default set to DataSource.SENTINEL2_L1C. However the layer you are using (in your case 'NDVI') needs to have satellite source set to Sentinel-2 L1C in Configurator. This is required even though you are actually using custom evalscript instead of the layer’s actual definition.


Note as well that you need to define each of these layers in the Configuration (instance), which you are using.

I noticed that you do not have any B0X bands there at all…


I suggest you create a new instance and use “Full WMS instance” as a template.


Ok thank you.

This should probably be mentioned in the s2cloudless example


Actually there are no advantages of using “Full WMS instance” comparing to any other instances. In either case you will have to create or use existing layer with Sentinel-2 L1C data source.


The predefined layers named B0X that you get in “Full WMS instance” are meant only for visualization and not for analysis. They are defined in a way that band values are non-linearly transformed for better visualization.


Reply