使用rasterio读取S3 Sentinel-2图像文件


12

使用rasterio打开Sentinel-2 AWS .jp2图像文件(当前由Sinergise托管,可以在此处找到)后,我当前遇到“访问被拒绝”错误。

我的代码如下所示:

import rasterio

access_key = '*****************'
secret_access_key = '***********************'
region_name = 'eu-central-1'

Session = rasterio.env.Env(aws_access_key_id=access_key,
             aws_secret_access_key=secret_access_key,
             region_name=region_name)

url = 's3://sentinel-pds/tiles/10/S/DG/2015/12/7/0/B01.jp2'

with Session:
    with rasterio.open(url) as dataset:
            print dataset

响应为:

---------------------------------------------------------------------------
CPLE_AWSAccessDenied                      Traceback (most recent call last)
<ipython-input-1-4f6da7274649> in <module>()
     12 
     13 with Session:
---> 14     with rasterio.open(url) as dataset:
     15         print dataset

/Users/Barney/anaconda/lib/python2.7/site-packages/rasterio/__init__.pyc in open(path, mode, driver, width, height, count, crs, transform, dtype, nodata,  **kwargs)
    191         raise ValueError(
    192             "mode string must be one of 'r', 'r+', or 'w', not %s" % mode)
--> 193     s.start()
    194     return s
    195 

rasterio/_base.pyx in rasterio._base.DatasetReader.start (rasterio/_base.c:2847)()

rasterio/_base.pyx in rasterio._base.DatasetReader.start (rasterio/_base.c:2799)()

rasterio/_err.pyx in rasterio._err.CPLErrors.check (rasterio/_err.c:1773)()

CPLE_AWSAccessDenied: Access Denied 

我不确定我是否正确使用了rasterio aws环境,即使提供了密钥和访问密钥,aws会话令牌密钥也需要吗?我还应该补充一点,如果提供Landsat-8网址(即http://landsat-pds.s3.amazonaws.com/L8/139/045/LC81390452014295LGN00/LC81390452014295LGN00_B1.TIF),则此功能可以正常运行

版本(通过Anaconda安装):

光栅-0.36.0

python-2.7

抱歉,以上内容含糊。我的问题是-为什么这适用于Landsat-8而不适用于Sentinel-2?如何使用rasterio打开Sentinel-2 AWS数据?

Answers:


9

我相信您使用的存储桶名称错误。应该是s3://sentinel-s2-l1c,不是s3://sentinel-pds

尝试:

url = 's3://sentinel-s2-l1c/tiles/10/S/DG/2015/12/7/0/B01.jp2'

在此处查看更多信息:http : //sentinel-pds.s3-website.eu-central-1.amazonaws.com/https://aws.amazon.com/public-datasets/sentinel-2/


+1 -AWS上Sentinel-2特别声明:“ LOCATION s3:// sentinel-s2-l1c”
user2856

是的,使用答案中的URL。答案应该被接受。注意:使用免费的JPEG 2000驱动程序访问这些JP2文件的性能较差。您需要使用(例如)免费的MrSID SDK从源代码构建GDAL,以获得JP2良好的性能。我想知道他们是否有理由使用JP2而不是GeoTIFF?
sgillies '16

@sgillies Dsoes意味着rasterio manylinux轮子也会遭受这种性能损失吗?您是否偶然进行了任何(公开的)基准/比较?
Kersten

1
我无法通过轮子分发MrSID SDK,因此它们使用了免费的基于Jasper的JP2驱动程序。我没有要发布的基准。
sgillies
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.