在 rasterio 中链接虚拟文件系统驱动程序

Chaining virtual file system drivers in rasterio

在简单的 gdal 中,将多个 vsi 驱动程序链接到例如直接访问 .tif.gz 文件:

import gdal
import rasterio as rio

## just an example, no real URL

# will work
ds = gdal.Open('/vsigzip//vsicurl/https://testdata.com/testimage.tif.gz')

# won't work
ds = rio.open('/vsigzip/https://testdata.com/testimage.tif.gz')

这是链接问题还是 rasterio 无法处理 .gz 个文件?

我只是 运行 通过这个和 RasterIO (v1.0.21) 中的 gzip 支持检查正常。您似乎刚刚错过了 //vsicurl.

import rasterio as rio

ds = rio.open('/vsigzip//vsicurl/http://localhost:8000/example.tif.gz')

http 服务器需要支持 运行ge 请求,但如果不支持,RasterIO 将产生特定的错误消息。

有趣的是 Apache Commons VFS scheme 在这里似乎不起作用;

ds = rio.open('gzip+http://localhost:8000/example.tif.gz')

生成以下内容。注意 vsicurl

之前缺少 /
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ubuntu/anaconda3/envs/rasterio-env/lib/python3.7/site-packages/rasterio/env.py", line 423, in wrapper
    return f(*args, **kwds)
  File "/home/ubuntu/anaconda3/envs/rasterio-env/lib/python3.7/site-packages/rasterio/__init__.py", line 216, in open
    s = DatasetReader(path, driver=driver, **kwargs)
  File "rasterio/_base.pyx", line 215, in rasterio._base.DatasetBase.__init__
rasterio.errors.RasterioIOError: '/vsizip/vsicurl/http://localhost:8000/example.tif.gz' does not exist in the file system, and is not recognized as a supported dataset name.