我在 Windows 上使用 sentinelhub-py 在 Python 中使用 sentinel hub API。
我正在按照此页面上的文档中所写的示例进行操作
以下代码通过API提取数据:首先evalscript选择波段数,SentinelHubRequest返回数据为.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()
此请求工作正常,但是当我将 MimeType 更改为 MimeType.TIFF 时,此错误不断出现:
DeflateError:libdeflate_zlib_decompress 返回 LIBDEFLATE_BAD_DATA
当我使用下面的代码下载所有 13 个波段的数据时,如下所示:https://sentinelhub-py.readthedocs.io/en/latest/examples/process_request.html#Example-3:-所有 Sentinel-2 的原始波段值
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()
然后尝试使用他们的代码生成一个 .TIFF 文件我得到这个错误:
DeflateError: libdeflate_zlib_decompress 返回 LIBDEFLATE_INSUFFICIENT_SPACE
我尝试的是生成一个只有 3 个波段的 .TIFF 文件,并将 sampleType 更改为“INT8”或将其删除,以及在 eval 脚本中删除 unit="DN"(数字),
我尝试将缓冲区大小增加到 10 GB
import os
# Set the buffer size to 10000 MB (in bytes)
buffer_size = 1024 * 1024 * 10000
os.environ['ZLIB_BUF_SIZE'] = str(buffer_size)
作为最后的手段,我安装了 gdal 库,但错误仍然存在,我找不到关于此错误的任何信息。
有没有人遇到过这个错误(我使用的是 Windows)并且可以为我提供提示或解决方案?