Windows下用Sentinel-hub API生成TIFF遇libdeflate解压错误求助
SentinelHub-Py生成TIFF文件时的DeflateError问题求助
问题现象
在Windows系统下使用Python的sentinelhub-py库调用Sentinel-hub API:
- 生成PNG文件的请求可正常运行;
- 将输出格式改为
MimeType.TIFF时,持续报错:DeflateError: libdeflate_zlib_decompress returned LIBDEFLATE_BAD_DATA; - 当请求全部13波段数据并生成TIFF文件时,报错:
DeflateError: libdeflate_zlib_decompress returned LIBDEFLATE_INSUFFICIENT_SPACE。
已尝试的解决方法
- 生成仅3波段的TIFF文件
- 修改evalscript中的
sampleType为"INT8"或省略该参数 - 移除evalscript中的
unit="DN"配置 - 设置环境变量
ZLIB_BUF_SIZE为10GB - 安装gdal库
以上操作均未解决问题,求相关解决思路或方案。
相关代码
生成PNG的正常代码
evalscript_true_color = """ //VERSION=3 function setup() { return { input: [{ bands: ["B02", "B03", "B04"] }], output: { bands: 3 } }; } function evaluatePixel(sample) { return [sample.B04, sample.B03, sample.B02]; } """ request_true_color = SentinelHubRequest( evalscript=evalscript_true_color, input_data=[ SentinelHubRequest.input_data( data_collection=DataCollection.SENTINEL2_L1C, time_interval=("2020-06-12", "2020-06-13"), ) ], responses=[SentinelHubRequest.output_response("default", MimeType.PNG)], bbox=betsiboka_bbox, size=betsiboka_size, config=config, ) true_color_imgs = request_true_color.get_data()
获取全部13波段数据的代码
evalscript_all_bands = """ //VERSION=3 function setup() { return { input: [{ bands: ["B01","B02","B03","B04","B05","B06","B07","B08","B8A","B09","B10","B11","B12"], units: "DN" }], output: { bands: 13, sampleType: "INT16" } }; } function evaluatePixel(sample) { return [sample.B01, sample.B02, sample.B03, sample.B04, sample.B05, sample.B06, sample.B07, sample.B08, sample.B8A, sample.B09, sample.B10, sample.B11, sample.B12]; } """ request_all_bands = SentinelHubRequest( evalscript=evalscript_all_bands, input_data=[ SentinelHubRequest.input_data( data_collection=DataCollection.SENTINEL2_L1C, time_interval=("2020-06-01", "2020-06-30"), mosaicking_order=MosaickingOrder.LEAST_CC, ) ], responses=[SentinelHubRequest.output_response("default", MimeType.TIFF)], bbox=betsiboka_bbox, size=betsiboka_size, config=config, ) all_bands_response = request_all_bands.get_data()
尝试设置缓冲区大小的代码
import os # Set the buffer size to 10000 MB (in bytes) buffer_size = 1024 * 1024 * 10000 os.environ['ZLIB_BUF_SIZE'] = str(buffer_size)
内容的提问来源于stack exchange,提问作者Francode77
相关产品推荐
相关产品推荐

