Thanks for you attention, I resolved the download, I think I have a problem with the .tiff format, specifically with the 32 bit format, but now I can’t download only ROI (region of interest) in one area (BBox). I think that the problem is in the parameters in custom_url_params. How could I solve the problem?
The code and the instance that I use is the following:
def save_sentinel_patch(height, data_folder):
INSTANCE_ID = '691eadb2-2dcc-4f23-ac65-MASKED'
bbox = BBox(bbox=[(-7223582,-3839077), (-7142680,-3897777)], crs=CRS.POP_WEB)
ROI = """MULTIPOLYGON(((-7179178.2313 -3859329.8432,
-7161416.6336 -3865178.1741,-7168239.6864 -3881965.0500,
-7187409.2156 -3876658.2312,-7179178.2313 -3859329.8432)))
"""
#layer = 'MOISTURE_INDEX'
layer = 'NDVI'
wms_bands_request = WmsRequest(data_folder=data_folder,
data_source=DataSource.SENTINEL2_L1C,
layer=layer,
bbox=bbox,
time='2017-12-06',
height=height,
#image_format=MimeType.TIFF_d32f,
image_format=MimeType.TIFF_d16,
#image_format=MimeType.TIFF_d8,
instance_id=INSTANCE_ID,
custom_url_params={CustomUrlParam.ATMFILTER: 'ATMCOR',
CustomUrlParam.TRANSPARENT: True,
CustomUrlParam.GEOMETRY: ROI,
#CustomUrlParam.EVALSCRIPT: ScaleColor,
CustomUrlParam.SHOWLOGO: False})
wms_img = wms_bands_request.get_data(save_data=True)
if not wms_img: # Image extraction Failed.
return False
else:
return True # Image succesfully extracted.
height = 3721
data_folder = '/Example/test_dir'
save_sentinel_patch(height, data_folder)
The error that is shown is:
C:\Users\car\Anaconda3\lib\site-packages\sentinelhub\download.py:127: UserWarning: File path examples\wms_TRUE_COLOR_EPSG3857_-7223582.0_-3897777.0_-7142680.0_-3839077.0_2019-01-20T14-21-53_1150X856_Geometry_MULTIPOLYGON(((-7179178.2313-3859329.8432,-7161416.6336-3865178.1741,-7168239.6864-3881965.0500,-7187409.2156-3876658.2312,-7179178.2313-3859329..png is longer than 255 character which might cause an error while saving on disk
'disk'.format(self.file_path))
Traceback (most recent call last):
File "<ipython-input-123-91796a54fbef>", line 1, in <module>
runfile('C:/Users/car/Documents/Example/save_png.py', wdir='C:/Users/carli/Documents/Example')
File "C:\Users\car\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
execfile(filename, namespace)
File "C:\Users\car\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/car/Documents/Example/save_png.py", line 42, in <module>
custom_wms_data = custom_wms_request.get_data(save_data=True)
File "C:\Users\car\Anaconda3\lib\site-packages\sentinelhub\data_request.py", line 104, in get_data
data_list = self._execute_data_download(data_filter, redownload, max_threads, raise_download_errors)
File "C:\Users\car\Anaconda3\lib\site-packages\sentinelhub\data_request.py", line 159, in _execute_data_download
data_list.append(future.result(timeout=SHConfig().download_timeout_seconds))
File "C:\Users\car\Anaconda3\lib\concurrent\futures\_base.py", line 425, in result
return self.__get_result()
File "C:\Users\car\Anaconda3\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception
File "C:\Users\car\Anaconda3\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\car\Anaconda3\lib\site-packages\sentinelhub\download.py", line 265, in execute_download_request
_save_if_needed(request, response_content)
File "C:\Users\car\Anaconda3\lib\site-packages\sentinelhub\download.py", line 392, in _save_if_needed
with open(file_path, 'wb') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'examples\wms_TRUE_COLOR_EPSG3857_-7223582.0_-3897777.0_-7142680.0_-3839077.0_2019-01-20T14-21-53_1150X856_Geometry_MULTIPOLYGON(((-7179178.2313-3859329.8432,-7161416.6336-3865178.1741,-7168239.6864-3881965.0500,-7187409.2156-3876658.2312,-7179178.2313-3859329..tiff'
Thanks