You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 16:47:37