File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/ogc.py:295, in WcsRequest.init(self, resx, resy, *kwargs)
255 def init(self, , resx: str = "10m", resy: str = "10m", kwargs: Any):
256 """
257 :param resx: resolution in x (resolution of a column) given in meters in the format (examples 10m,
258 20m, ...). Default is 10m, which is the best native resolution of some Sentinel-2 bands.
(...)
293 :param config: A custom instance of config class to override parameters from the saved configuration.
294 """
--> 295 super().init(service_type=ServiceType.WCS, size_x=resx, size_y=resy, kwargs)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/ogc.py:335, in OgcImageService.get_request(self, request)
320 """Get download requests
321
322 Create a list of DownloadRequests for all Sentinel-2 acquisitions within request's time interval and
(...)
327 :return: list of DownloadRequests
328 """
329 size_x, size_y = self.get_image_dimensions(request)
330 return [
331 DownloadRequest(
332 url=self.get_url(request=request, date=date, size_x=size_x, size_y=size_y),
333 data_type=request.image_format,
334 )
--> 335 for date in self.get_dates(request)
336 ]
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/wfs.py:127, in WebFeatureService.get_dates(self)
121 """Returns a list of acquisition times from tile info data
122
123 :return: List of acquisition times in the order returned by WFS service.
124 """
125 tile_dates: List[Optional[dt.date]] = []
--> 127 for tile_info in self:
128 if not tile_info["properties"]["date"]: # could be True for custom (BYOC) data collections
129 tile_dates.append(None)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/base.py:274, in FeatureIterator.next(self)
269 """Method called to provide the next feature in iteration
270
271 :return: the next feature
272 """
273 while self.index >= len(self.features) and not self.finished:
--> 274 new_features = self._fetch_features()
275 self.features.extend(new_features)
277 if self.index < len(self.features):
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/client.py:249, in DownloadClient.get_json_dict(self, url, extract_key, *args, kwargs)
241 def get_json_dict(self, url: str, *args: Any, extract_key: Optional[str] = None, *kwargs: Any) -> JsonDict:
242 """Download request as JSON data type, failing if the result is not a dictionary
243
244 For other parameters see get_json method.
(...)
247 :param extract_key: If provided, the field is automatically extracted, checked, and returned
248 """
--> 249 response = self.get_json(url, args, kwargs)
251 if not isinstance(response, dict):
252 raise MissingDataInRequestException(
253 f"Response from {url} was expected to be a dictionary, but got {type(response)}."
254 )
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/client.py:117, in DownloadClient._single_download_decoded(self, request)
115 def _single_download_decoded(self, request: DownloadRequest) -> Any:
116 """Downloads a response and decodes it into data. By decoding a single response"""
--> 117 response = self._single_download(request)
118 return None if response is None else response.decode()
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/client.py:130, in DownloadClient._single_download(self, request)
128 no_local_data = self.redownload or response_path is None or not os.path.exists(response_path)
129 if no_local_data:
--> 130 response = self._execute_download(request)
131 else:
132 if not request.return_data or response_path is None:
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/handlers.py:64, in retry_temporary_errors..new_download_func(self, request)
62 for attempt_idx in range(download_attempts):
63 try:
---> 64 return download_func(self, request)
66 except requests.RequestException as exception:
67 attempts_left = download_attempts - (attempt_idx + 1)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/handlers.py:43, in fail_user_errors..new_download_func(self, request)
38 except requests.HTTPError as exception:
39 if (
40 exception.response.status_code < requests.status_codes.codes.INTERNAL_SERVER_ERROR
41 and exception.response.status_code != requests.status_codes.codes.TOO_MANY_REQUESTS
42 ):
---> 43 raise DownloadFailedException(
44 _create_download_failed_message(exception, request.url), request_exception=exception
45 ) from exception
46 raise exception from exception
Based on the error, I would suggest you verify the shapes you are providing in a different GIS program. It seems that they do not intersect. You can also try running the code without providing the BBOX.
In the file: earth_observation_with_StatAPI.ipynb
code no: 12
code:
"wcs_true_color_request = WcsRequest( data_collection=DataCollection.SENTINEL2_L1C, data_folder="./cache/", layer='TRUE-COLOR-S2-L1C', bbox=bbox, time=time_interval, resx = "10m", resy = "10m", image_format= MimeType.TIFF ) images = wcs_true_color_request.get_data(save_data=True) len(images)"
output:
"
HTTPError Traceback (most recent call last) File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/handlers.py:37, in fail_user_errors..new_download_func(self, request)
36 try:
---> 37 return download_func(self, request)
38 except requests.HTTPError as exception:
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/sentinelhub_client.py:90, in SentinelHubDownloadClient._execute_download(self, request) 88 continue ---> 90 response.raise_for_status() 92 LOGGER.debug("Successful %s request to %s", request.request_type.value, request.url)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/requests/models.py:1021, in Response.raise_for_status(self) 1020 if http_error_msg: -> 1021 raise HTTPError(http_error_msg, response=self)
HTTPError: 400 Client Error: Bad Request for url: https://services.sentinel-hub.com/ogc/wfs/c294be23-f885-44c2-80fb-b867750a1bfa?SERVICE=wfs&WARNINGS=False&REQUEST=GetFeature&TYPENAMES=DSS1&BBOX=46.11%2C14.26%2C46.26%2C14.51&OUTPUTFORMAT=application%2Fjson&SRSNAME=EPSG%3A4326&TIME=2023-01-01T00%3A00%3A00Z%2F2023-05-01T23%3A59%3A59Z&MAXCC=100.0&MAXFEATURES=100&FEATURE_OFFSET=0
The above exception was the direct cause of the following exception:
DownloadFailedException Traceback (most recent call last) Cell In[12], line 1 ----> 1 wcs_true_color_request = WcsRequest( 2 data_collection=DataCollection.SENTINEL2_L1C, 3 data_folder="./cache/", 4 layer='TRUE-COLOR-S2-L1C', 5 bbox=bbox, 6 time=time_interval, 7 resx = "10m", 8 resy = "10m", 9 image_format= MimeType.TIFF 10 ) 11 images = wcs_true_color_request.get_data(save_data=True) 12 len(images)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/ogc.py:295, in WcsRequest.init(self, resx, resy, *kwargs) 255 def init(self, , resx: str = "10m", resy: str = "10m", kwargs: Any): 256 """ 257 :param resx: resolution in x (resolution of a column) given in meters in the format (examples
10m
, 25820m
, ...). Default is10m
, which is the best native resolution of some Sentinel-2 bands. (...) 293 :param config: A custom instance of config class to override parameters from the saved configuration. 294 """ --> 295 super().init(service_type=ServiceType.WCS, size_x=resx, size_y=resy, kwargs)File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/ogc.py:132, in OgcRequest.init(self, layer, bbox, data_collection, time, service_type, size_x, size_y, maxcc, image_format, custom_url_params, time_difference, kwargs) 128 self._check_custom_url_parameters() 130 self.wfs_iterator: Optional[WebFeatureService] = None --> 132 super().init(SentinelHubDownloadClient, kwargs)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/base.py:37, in DataRequest.init(self, download_client_class, data_folder, config) 35 self.download_list: List[DownloadRequest] = [] 36 self.folder_list: List[str] = [] ---> 37 self.create_request()
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/ogc.py:163, in OgcRequest.create_request(self, reset_wfs_iterator) 160 self.wfs_iterator = None 162 ogc_service = OgcImageService(config=self.config) --> 163 self.download_list = ogc_service.get_request(self) 164 self.wfs_iterator = ogc_service.get_wfs_iterator()
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/ogc.py:335, in OgcImageService.get_request(self, request) 320 """Get download requests 321 322 Create a list of DownloadRequests for all Sentinel-2 acquisitions within request's time interval and (...) 327 :return: list of DownloadRequests 328 """ 329 size_x, size_y = self.get_image_dimensions(request) 330 return [ 331 DownloadRequest( 332 url=self.get_url(request=request, date=date, size_x=size_x, size_y=size_y), 333 data_type=request.image_format, 334 ) --> 335 for date in self.get_dates(request) 336 ]
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/ogc.py:545, in OgcImageService.get_dates(self, request) 542 else: 543 self.wfs_iterator = request.wfs_iterator --> 545 dates = self.wfs_iterator.get_dates() 546 dates = filter_times(dates, request.time_difference) # type: ignore[type-var] 548 LOGGER.debug("Initializing requests for dates: %s", dates)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/wfs.py:127, in WebFeatureService.get_dates(self) 121 """Returns a list of acquisition times from tile info data 122 123 :return: List of acquisition times in the order returned by WFS service. 124 """ 125 tile_dates: List[Optional[dt.date]] = [] --> 127 for tile_info in self: 128 if not tile_info["properties"]["date"]: # could be True for custom (BYOC) data collections 129 tile_dates.append(None)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/base.py:274, in FeatureIterator.next(self) 269 """Method called to provide the next feature in iteration 270 271 :return: the next feature 272 """ 273 while self.index >= len(self.features) and not self.finished: --> 274 new_features = self._fetch_features() 275 self.features.extend(new_features) 277 if self.index < len(self.features):
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/api/wfs.py:105, in WebFeatureService._fetch_features(self) 102 params: JsonDict = {**self.params, "FEATURE_OFFSET": self.next} 103 url = f"{self.url}?{urlencode(params)}" --> 105 new_features = self.client.get_json_dict(url)["features"] 107 if len(new_features) < self.max_features_per_request or self.latest_time_only: 108 self.finished = True
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/client.py:249, in DownloadClient.get_json_dict(self, url, extract_key, *args, kwargs) 241 def get_json_dict(self, url: str, *args: Any, extract_key: Optional[str] = None, *kwargs: Any) -> JsonDict: 242 """Download request as JSON data type, failing if the result is not a dictionary 243 244 For other parameters see
get_json
method. (...) 247 :param extract_key: If provided, the field is automatically extracted, checked, and returned 248 """ --> 249 response = self.get_json(url, args, kwargs) 251 if not isinstance(response, dict): 252 raise MissingDataInRequestException( 253 f"Response from {url} was expected to be a dictionary, but got {type(response)}." 254 )File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/client.py:239, in DownloadClient.get_json(self, url, post_values, headers, request_type, kwargs) 228 json_headers = {"Content-Type": MimeType.JSON.get_string(), json_headers} 230 request = DownloadRequest( 231 url=url, 232 headers=json_headers, (...) 236 **kwargs, 237 ) --> 239 return self._single_download_decoded(request)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/client.py:117, in DownloadClient._single_download_decoded(self, request) 115 def _single_download_decoded(self, request: DownloadRequest) -> Any: 116 """Downloads a response and decodes it into data. By decoding a single response""" --> 117 response = self._single_download(request) 118 return None if response is None else response.decode()
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/client.py:130, in DownloadClient._single_download(self, request) 128 no_local_data = self.redownload or response_path is None or not os.path.exists(response_path) 129 if no_local_data: --> 130 response = self._execute_download(request) 131 else: 132 if not request.return_data or response_path is None:
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/handlers.py:64, in retry_temporary_errors..new_download_func(self, request)
62 for attempt_idx in range(download_attempts):
63 try:
---> 64 return download_func(self, request)
66 except requests.RequestException as exception:
67 attempts_left = download_attempts - (attempt_idx + 1)
File ~/Downloads/ENTER/envs/eo/lib/python3.10/site-packages/sentinelhub/download/handlers.py:43, in fail_user_errors..new_download_func(self, request)
38 except requests.HTTPError as exception:
39 if (
40 exception.response.status_code < requests.status_codes.codes.INTERNAL_SERVER_ERROR
41 and exception.response.status_code != requests.status_codes.codes.TOO_MANY_REQUESTS
42 ):
---> 43 raise DownloadFailedException(
44 _create_download_failed_message(exception, request.url), request_exception=exception
45 ) from exception
46 raise exception from exception
DownloadFailedException: Failed to download from: https://services.sentinel-hub.com/ogc/wfs/c294be23-f885-44c2-80fb-b867750a1bfa?SERVICE=wfs&WARNINGS=False&REQUEST=GetFeature&TYPENAMES=DSS1&BBOX=46.11%2C14.26%2C46.26%2C14.51&OUTPUTFORMAT=application%2Fjson&SRSNAME=EPSG%3A4326&TIME=2023-01-01T00%3A00%3A00Z%2F2023-05-01T23%3A59%3A59Z&MAXCC=100.0&MAXFEATURES=100&FEATURE_OFFSET=0 with HTTPError: 400 Client Error: Bad Request for url: https://services.sentinel-hub.com/ogc/wfs/c294be23-f885-44c2-80fb-b867750a1bfa?SERVICE=wfs&WARNINGS=False&REQUEST=GetFeature&TYPENAMES=DSS1&BBOX=46.11%2C14.26%2C46.26%2C14.51&OUTPUTFORMAT=application%2Fjson&SRSNAME=EPSG%3A4326&TIME=2023-01-01T00%3A00%3A00Z%2F2023-05-01T23%3A59%3A59Z&MAXCC=100.0&MAXFEATURES=100&FEATURE_OFFSET=0 Server response: "Parameter GEOMETRY and BBOX and the instance area of interest (if set) must intersect!" "
Please help..