虚拟文件

AWS S3

注解

要求GDAL 2.1.0

这是必须通过执行来安装的额外功能

pip install rasterio[s3]

在按照中的说明配置了AWS凭据之后, boto3 guide 您可以从存储为S3对象的TIFF中读取元数据和图像,而无需更改代码。

with rasterio.open('s3://landsat-pds/L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF') as src:
    print(src.profile)

# Printed:
# {'blockxsize': 512,
#  'blockysize': 512,
#  'compress': 'deflate',
#  'count': 1,
#  'crs': {'init': u'epsg:32645'},
#  'driver': u'GTiff',
#  'dtype': 'uint16',
#  'height': 7791,
#  'interleave': 'band',
#  'nodata': None,
#  'tiled': True,
#  'transform': Affine(30.0, 0.0, 381885.0,
#        0.0, -30.0, 2512815.0),
#  'width': 7621}

注解

AWS的定价问题虽然与下载整个TIFF并在本地打开相比,从S3读取更少的字节可以减少延迟,但它确实至少发出3个获取TIFF的请求。 profile 如上图所示,可能更多的是从TIFF获取所有图像。在决定是否 aws.Session 是给你的。