在简单的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
文件?
答案 0 :(得分:1)
我刚刚经历了这一点,并且RasterIO(v1.0.21)中的gzip支持检查正常。似乎您刚刚错过了//vsicurl
。
import rasterio as rio
ds = rio.open('/vsigzip//vsicurl/http://localhost:8000/example.tif.gz')
http服务器需要支持范围请求,但是如果不支持,则RasterIO会生成特定的错误消息。
有趣的是,this在这里似乎不起作用;
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.