首页 > 解决方案 > 如何从 url 读取 tiff 文件

问题描述

我在下面发布了网络服务。打开时的 url 应该返回一个tiff文件。当我运行此代码时,我收到以下错误消息

`(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:`

请让我知道如何接收和读取从 url 返回的 tiff 文件

代码

@app.route("/getTIFFForURL/<string:polygonCoordinates>", methods=['GET'] )
def getTIFFForURL(polygonCoordin/ates):
    url = config['EndPoint']['https'] + config['SYNOPSEndPoint']['rasterInPolygonEndPoint'] + config['SYNOPSEndPoint']['polygonToken'] + config['SYNOPSEndPoint']['polygonDelimiterOpen'] + polygonCoordinates + config['SYNOPSEndPoint']['polygonDelimiterClose'] + config['SYNOPSEndPoint']['rasterInPolygonResolutionToken']
    url = url.replace(" ","%20")
    url = url.replace("&","%26")
    backendResponseAsTIFF = readResponseAsTIFFForURL(url)
    return json.dumps(backendResponseAsTIFF)


def readResponseAsTIFFForURL(baseURL):
    # TODO: remove before production:
    resp = requests.get(baseURL)
    tiffContents = tiff.imread(io.BytesIO(resp.content))
    logger.debug(tiffContents)
    return "OK"

标签: python

解决方案


推荐阅读