我已通过 geopandas 成功从我的 S3 存储桶中读取了 zip 格式的 shapefile,但在尝试将相同的地理数据帧作为 shapefile 输出到同一 S3 存储桶时出现错误。
下面的代码是我读取 zip 文件的方式,效果很好:
## session for connecting to S3
session = boto3.session.Session(aws_access_key_id='MY-KEY-ID',
aws_secret_access_key='MY-KEY')
s3 = session.resource('s3')
bucket = s3.Bucket('my_bucket')
## read shapefile
TPG = bucket.Object(key='/shapefiles/grid.zip')
TPGrid = geopandas.read_file(TPG.get()['Body'])
Run Code Online (Sandbox Code Playgroud)
但是当我尝试输出相同的地理数据框时,如下所示:
TPGrid.to_file(filename='s3://my_bucket/output/TPGrid.zip', driver='ESRI Shapefile')
Run Code Online (Sandbox Code Playgroud)
我会得到错误代码:
ERROR:fiona._env:Only read-only mode is supported for /vsicurl
ERROR:fiona._env:Only read-only mode is supported for /vsicurl
ERROR:fiona._env:Only read-only mode is supported for /vsicurl
ERROR:fiona._env:Unable to open /vsis3/my_bucket/output/TPGrid.zip/TPGrid.shp or /vsis3/my_bucket/output/TPGrid.zip/TPGrid.SHP.
Traceback (most recent call last):
File "fiona/ogrext.pyx", line …Run Code Online (Sandbox Code Playgroud)