sentinel-hub / field-delineation

Field delineation with Sentinel-2 data from Sentinel-Hub and a ResUnet-a architecture.
MIT License
149 stars 53 forks source link

BUG on the batch_download(download_config) #16

Closed aidos2 closed 2 years ago

aidos2 commented 2 years ago

Dear collegues, I need really help. Recently I bought Enterprice S account for testing this workflow for my AOI. Especifically I would like to run it for whole country. Althought I set up all sentinelhub configuration, I am facing an ERROR below. Also, my input AOI crs is WGS 84. C:\Users\aidos\AppData\Roaming\Python\Python39\site-packages\fd-1.0.0-py3.9.egg\fd\download.py:49: ShapelyDeprecationWarning: Iteration over multi-part geometries is deprecated and will be removed in Shapely 2.0. Use thegeoms` property to access the constituent parts of a multi-part geometry. return sum(len(poly.exterior.coords) for poly in geometry)

HTTPError Traceback (most recent call last) ~\miniconda3\envs\ai_fields\lib\site-packages\sentinelhub\download\handlers.py in new_download_func(self, request) 19 try: ---> 20 return download_func(self, request) 21 except requests.HTTPError as exception:

~\miniconda3\envs\ai_fields\lib\site-packages\sentinelhub\download\sentinelhub_client.py in _execute_download(self, request) 79 ---> 80 response.raise_for_status() 81

~\miniconda3\envs\ai_fields\lib\site-packages\requests\models.py in raise_for_status(self) 959 if http_error_msg: --> 960 raise HTTPError(http_error_msg, response=self) 961

HTTPError: 400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/batch/process

The above exception was the direct cause of the following exception:

DownloadFailedException Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_10080\1061056470.py in <cell line: 1>() ----> 1 batch_download(download_config)

~\AppData\Roaming\Python\Python39\site-packages\fd-1.0.0-py3.9.egg\fd\scripts\download.py in batch_download(config) 79 LOGGER.info('Creating SH Batch request') 80 batch = SentinelHubBatch() ---> 81 batch_request = create_batch_request( 82 batch=batch, 83 config=download_config,

~\AppData\Roaming\Python\Python39\site-packages\fd-1.0.0-py3.9.egg\fd\download.py in create_batch_request(batch, config, output_responses, description) 196 ) 197 --> 198 batch_request = batch.create( 199 sentinelhub_request=sentinelhub_request, 200 tiling_grid=SentinelHubBatch.tiling_grid(

~\miniconda3\envs\ai_fields\lib\site-packages\sentinelhub\api\batch.py in create(self, sentinelhub_request, tiling_grid, output, bucket_name, description, **kwargs) 81 82 url = self._get_process_url() ---> 83 request_info = self.client.get_json(url, post_values=payload, use_session=True) 84 85 return BatchRequest.from_dict(request_info)

~\miniconda3\envs\ai_fields\lib\site-packages\sentinelhub\download\client.py in get_json(self, url, post_values, headers, request_type, kwargs) 217 ) 218 --> 219 return self._single_download(request, decode_data=True) 220 221 def get_xml(self, url, kwargs):

~\miniconda3\envs\ai_fields\lib\site-packages\sentinelhub\download\client.py in _single_download(self, request, decode_data) 117 return None 118 --> 119 response_content = self._execute_download(request) 120 121 if request_path and request.save_response and (self.redownload or not os.path.exists(request_path)):

~\miniconda3\envs\ai_fields\lib\site-packages\sentinelhub\download\handlers.py in new_download_func(self, request) 41 for attempt_num in range(download_attempts): 42 try: ---> 43 return download_func(self, request) 44 except requests.RequestException as exception: 45

~\miniconda3\envs\ai_fields\lib\site-packages\sentinelhub\download\handlers.py in new_download_func(self, request) 25 ): 26 ---> 27 raise DownloadFailedException(_create_download_failed_message(exception, request.url)) from exception 28 raise exception from exception 29

DownloadFailedException: Failed to download from: https://services.sentinel-hub.com/api/v1/batch/process with HTTPError: 400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/batch/process Server response: "{"error":{"status":400,"reason":"Bad Request","message":"Invalid request","code":"COMMON_BAD_PAYLOAD","errors":[{"parameter":"output->defaultTilePath","invalidValue":"s3://adiya2020/s3://adiya2020/BATCH_TIFFS_FOLDER///.","violation":"Invalid tilePath: must not contain trailing or consecutive slashes, except in the protocol specification 's3://...'."}]}}" `

batic commented 2 years ago

Hi @aidos2

Based on the fact that the defaultTilePath is raising an "invalid value" error, I'd say you have not set up the BATCH_TIFFS_FOLDER variable in the notebook. The variable should not include the s3://bucket_name/, so in your case something like

BATCH_TIFFS_FOLDER = "BATCH_TIFFS_FOLDER"

should work.

aidos2 commented 2 years ago

Hello, Thanks for response. However, in the notebook they wrote (# Location on the bucket to which EOPatches will be saved.) Also, I modified to my code and show the local folder in my OS.

Then another error

DownloadFailedException: Failed to download from: https://services.sentinel-hub.com/api/v1/batch/process with HTTPError: 400 Client Error: Bad Request for url: https://services.sentinel-hub.com/api/v1/batch/process Server response: "{"error":{"status":400,"reason":"Bad Request","message":"Access denied - bucket in wrong AWS region or not writable by Sentinel Hub","code":"COMMON_BAD_PAYLOAD"}}"

batic commented 2 years ago

# Location _on_ the bucket might be a bit unclear; the variable is (in terms of AWS S3 terminology) a prefix on the bucket, meaning the bucket name should not be included.

Regarding the bucket, you should follow the instructions on setting up a bucket for Sentinel Hub Batch process API. Please have a look at docs

Regarding running the field delineation using local folder you might experience some issues - we've intended the notebook to be run using S3 bucket. But you can always do first part on s3 (e.g. Batch process to download data), then copy everything to your machine (mind you - this might be a lot of data), and continue from there resetting the project folder to local folder where you copied the data.

aidos2 commented 2 years ago

Thank you so much, I have figure out the issue.